Move service worker into platform
parent
87e67d8168
commit
e077d9ca5f
|
@ -29,11 +29,6 @@ require('katex/dist/katex.css');
|
|||
import {parseQsFromFragment} from "./url_utils";
|
||||
import './modernizr';
|
||||
|
||||
// load service worker if available on this platform
|
||||
if (!window.electron && 'serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('sw.js');
|
||||
}
|
||||
|
||||
async function settled(...promises: Array<Promise<any>>) {
|
||||
for (const prom of promises) {
|
||||
try {
|
||||
|
|
|
@ -49,6 +49,8 @@ export function preparePlatform() {
|
|||
console.log("Using Web platform");
|
||||
PlatformPeg.set(new WebPlatform());
|
||||
}
|
||||
// Register service worker if available on this platform
|
||||
PlatformPeg.get().registerServiceWorker();
|
||||
}
|
||||
|
||||
export async function loadConfig() {
|
||||
|
|
|
@ -38,6 +38,12 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
return 'Web Platform'; // no translation required: only used for analytics
|
||||
}
|
||||
|
||||
registerServiceWorker(): void {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('sw.js');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the platform supports displaying
|
||||
* notifications, otherwise false.
|
||||
|
|
Loading…
Reference in New Issue