refactor: btns fallback
This commit is contained in:
parent
9aa6c406c6
commit
837b960e88
2 changed files with 8 additions and 3 deletions
|
@ -160,7 +160,7 @@ export namespace BtnAction {
|
|||
})
|
||||
}
|
||||
|
||||
export const download = (url: UrlInput, fallback?: () => Promisable<void>, timeout = 30 * 1000): BtnAction => {
|
||||
export const download = (url: UrlInput, fallback?: () => Promisable<void>, timeout = Infinity): BtnAction => {
|
||||
return process(async (): Promise<void> => {
|
||||
try {
|
||||
const _url = await useTimeout(normalizeUrlInput(url), timeout)
|
||||
|
|
|
@ -14,6 +14,11 @@ const main = (): void => {
|
|||
const filename = scoreinfo.fileName
|
||||
|
||||
let indvPartBtn: HTMLButtonElement | null = null
|
||||
const timeout = 30 * 1000 // 30s
|
||||
const fallback = () => {
|
||||
// btns fallback to load from MSCZ file (`Individual Parts`)
|
||||
return indvPartBtn?.click()
|
||||
}
|
||||
|
||||
btnList.add({
|
||||
name: i18n('DOWNLOAD')('MSCZ'),
|
||||
|
@ -37,12 +42,12 @@ const main = (): void => {
|
|||
|
||||
btnList.add({
|
||||
name: i18n('DOWNLOAD')('MIDI'),
|
||||
action: BtnAction.download(() => getFileUrl('midi'), () => indvPartBtn?.click()),
|
||||
action: BtnAction.download(() => getFileUrl('midi'), fallback, timeout),
|
||||
})
|
||||
|
||||
btnList.add({
|
||||
name: i18n('DOWNLOAD')('MP3'),
|
||||
action: BtnAction.download(() => getFileUrl('mp3'), () => indvPartBtn?.click()),
|
||||
action: BtnAction.download(() => getFileUrl('mp3'), fallback, timeout),
|
||||
})
|
||||
|
||||
indvPartBtn = btnList.add({
|
||||
|
|
Loading…
Reference in a new issue