web/download: show an explanation when user activation expires
This commit is contained in:
parent
dcbda243a2
commit
fbe8ccfc2a
2 changed files with 12 additions and 4 deletions
|
@ -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",
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue