split serviceWorker and streamDownload capabilities

This commit is contained in:
Danny Coates 2018-12-10 12:47:23 -08:00
parent 81cf84b131
commit 61299dd8ea
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
2 changed files with 6 additions and 5 deletions

View File

@ -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
};
}

View File

@ -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);