feat: deprecation notice of `Download PDF` and `Download MIDI`, use `Individual Parts` instead

This commit is contained in:
Xmader 2020-10-22 17:12:44 -04:00
parent 21d5002575
commit 867174be68
2 changed files with 18 additions and 2 deletions

View File

@ -87,6 +87,10 @@ export namespace BtnAction {
export const PROCESSING_TEXT = 'Processing…'
export const ERROR_TEXT = '❌Download Failed!'
const deprecationNotice = (btnName: string): string => {
return `DEPRECATED! (may still work)\n\nUse \`${btnName}\` inside \`Individual Parts\` instead.`
}
type Promisable<T> = T | Promise<T>
type UrlInput = Promisable<string> | (() => Promisable<string>)
@ -160,4 +164,12 @@ export namespace BtnAction {
}
}
export const deprecate = (action: BtnAction): BtnAction => {
return (name, btn, setText) => {
alert(deprecationNotice(name))
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return action(name, btn, setText)
}
}
}

View File

@ -27,7 +27,9 @@ const main = (): void => {
btnList.add({
name: 'Download PDF',
action: BtnAction.process(downloadPDF),
action: BtnAction.deprecate(
BtnAction.process(downloadPDF),
),
})
btnList.add({
@ -42,7 +44,9 @@ const main = (): void => {
btnList.add({
name: 'Download MIDI',
action: BtnAction.download(() => getFileUrl('midi'), `${filename}.mid`),
action: BtnAction.deprecate(
BtnAction.download(() => getFileUrl('midi'), `${filename}.mid`),
),
})
btnList.add({