split serviceWorker and streamDownload capabilities
This commit is contained in:
parent
81cf84b131
commit
61299dd8ea
|
@ -75,6 +75,7 @@ async function polyfillStreams() {
|
|||
}
|
||||
|
||||
export default async function capabilities() {
|
||||
const serviceWorker = 'serviceWorker' in navigator;
|
||||
let crypto = await checkCrypto();
|
||||
const nativeStreams = checkStreams();
|
||||
let polyStreams = false;
|
||||
|
@ -91,11 +92,10 @@ export default async function capabilities() {
|
|||
return {
|
||||
account,
|
||||
crypto,
|
||||
serviceWorker,
|
||||
streamUpload: nativeStreams || polyStreams,
|
||||
streamDownload:
|
||||
nativeStreams &&
|
||||
'serviceWorker' in navigator &&
|
||||
browserName() !== 'safari',
|
||||
nativeStreams && serviceWorker && browserName() !== 'safari',
|
||||
multifile: nativeStreams || polyStreams
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,8 +28,9 @@ if (process.env.NODE_ENV === 'production') {
|
|||
(async function start() {
|
||||
const app = routes(choo());
|
||||
const capa = await capabilities();
|
||||
if (capa.streamDownload) {
|
||||
navigator.serviceWorker.register('/serviceWorker.js');
|
||||
if (capa.serviceWorker) {
|
||||
await navigator.serviceWorker.register('/serviceWorker.js');
|
||||
await navigator.serviceWorker.ready;
|
||||
}
|
||||
|
||||
const translate = await getTranslator(LOCALE);
|
||||
|
|
Loading…
Reference in New Issue