From 867174be686c1e22365584fc75deb35645edea74 Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 22 Oct 2020 17:12:44 -0400 Subject: [PATCH] feat: deprecation notice of `Download PDF` and `Download MIDI`, use `Individual Parts` instead --- src/btn.ts | 12 ++++++++++++ src/main.ts | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/btn.ts b/src/btn.ts index 1b42c0c..e55f5a7 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -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 | Promise type UrlInput = Promisable | (() => Promisable) @@ -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) + } + } + } diff --git a/src/main.ts b/src/main.ts index 60e09cc..cf991d5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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({