mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix "Download All" for Safari (#5910)
* Fix download all for Safari Added check to use fallback downloader for iOS Added check for safari to use the delayed download function Remove old comment about firefox, as a.click() supported since Firefox 75 (2020) Fixes: #5672 * Change download to always use setTimeout Instead of conditionally using setTimeout based on browser, we should always use it since it sometimes also misses some episodes. * Update formatting --------- Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>
This commit is contained in:
parent
44afbc2357
commit
4071c44437
1 changed files with 3 additions and 17 deletions
|
@ -27,19 +27,11 @@ function fallback(urls) {
|
|||
})();
|
||||
}
|
||||
|
||||
function sameDomain(url) {
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
||||
return window.location.hostname === a.hostname && window.location.protocol === a.protocol;
|
||||
}
|
||||
|
||||
function download(url) {
|
||||
const a = document.createElement('a');
|
||||
a.download = '';
|
||||
a.href = url;
|
||||
// firefox doesn't support `a.click()`...
|
||||
a.dispatchEvent(new MouseEvent('click'));
|
||||
a.click();
|
||||
}
|
||||
|
||||
export default function (urls) {
|
||||
|
@ -47,19 +39,13 @@ export default function (urls) {
|
|||
throw new Error('`urls` required');
|
||||
}
|
||||
|
||||
if (typeof document.createElement('a').download === 'undefined') {
|
||||
if (typeof document.createElement('a').download === 'undefined' || browser.iOS) {
|
||||
return fallback(urls);
|
||||
}
|
||||
|
||||
let delay = 0;
|
||||
|
||||
urls.forEach(function (url) {
|
||||
// the download init has to be sequential for firefox if the urls are not on the same domain
|
||||
if (browser.firefox && !sameDomain(url)) {
|
||||
setTimeout(download.bind(null, url), 100 * ++delay);
|
||||
return;
|
||||
}
|
||||
|
||||
download(url);
|
||||
setTimeout(download.bind(null, url), 100 * ++delay);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue