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() { export default async function capabilities() {
const serviceWorker = 'serviceWorker' in navigator;
let crypto = await checkCrypto(); let crypto = await checkCrypto();
const nativeStreams = checkStreams(); const nativeStreams = checkStreams();
let polyStreams = false; let polyStreams = false;
@ -91,11 +92,10 @@ export default async function capabilities() {
return { return {
account, account,
crypto, crypto,
serviceWorker,
streamUpload: nativeStreams || polyStreams, streamUpload: nativeStreams || polyStreams,
streamDownload: streamDownload:
nativeStreams && nativeStreams && serviceWorker && browserName() !== 'safari',
'serviceWorker' in navigator &&
browserName() !== 'safari',
multifile: nativeStreams || polyStreams multifile: nativeStreams || polyStreams
}; };
} }

View File

@ -28,8 +28,9 @@ if (process.env.NODE_ENV === 'production') {
(async function start() { (async function start() {
const app = routes(choo()); const app = routes(choo());
const capa = await capabilities(); const capa = await capabilities();
if (capa.streamDownload) { if (capa.serviceWorker) {
navigator.serviceWorker.register('/serviceWorker.js'); await navigator.serviceWorker.register('/serviceWorker.js');
await navigator.serviceWorker.ready;
} }
const translate = await getTranslator(LOCALE); const translate = await getTranslator(LOCALE);