diff --git a/web/i18n/en/dialog.json b/web/i18n/en/dialog.json index 12b3652d..a2688f6d 100644 --- a/web/i18n/en/dialog.json +++ b/web/i18n/en/dialog.json @@ -9,6 +9,7 @@ "saving.title": "choose how to save", "saving.blocked": "cobalt tried opening the file in a new tab, but your browser blocked it. you can allow pop-ups for cobalt to prevent this from happening next time.", + "saving.timeout": "cobalt tried saving the file automatically, but your browser stopped it. you have to select a preferred method manually.", "safety.title": "important safety notice", diff --git a/web/src/lib/download.ts b/web/src/lib/download.ts index 9ed1042e..785d520d 100644 --- a/web/src/lib/download.ts +++ b/web/src/lib/download.ts @@ -65,18 +65,25 @@ export const downloadFile = ({ url, file }: { url?: string, file?: File }) => { const pref = get(settings).save.savingMethod; + if (pref === "ask") { + return openSavingDialog({ url, file }); + } + /* user actions (such as invoke share, open new tab) have expiration. in webkit, for example, that timeout is 5 seconds. - https://github.com/WebKit/WebKit/blob/b838f8bb3573bd5906bc5f02fcc8cb274b3c9b8a/Source/WebCore/page/LocalDOMWindow.cpp#L167 + https://github.com/WebKit/WebKit/blob/b838f8bb/Source/WebCore/page/LocalDOMWindow.cpp#L167 navigator.userActivation.isActive makes sure that we're still able to invoke an action without the user agent interrupting it. if not, we show a saving dialog for user to re-invoke that action. */ - - if (pref === "ask" || !navigator.userActivation.isActive) { - return openSavingDialog({ url, file }); + if (!navigator.userActivation.isActive) { + return openSavingDialog({ + url, + file, + body: get(t)("dialog.saving.timeout"), + }); } try {