Move service worker into platform
This commit is contained in:
@@ -29,11 +29,6 @@ require('katex/dist/katex.css');
|
|||||||
import {parseQsFromFragment} from "./url_utils";
|
import {parseQsFromFragment} from "./url_utils";
|
||||||
import './modernizr';
|
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>>) {
|
async function settled(...promises: Array<Promise<any>>) {
|
||||||
for (const prom of promises) {
|
for (const prom of promises) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ export function preparePlatform() {
|
|||||||
console.log("Using Web platform");
|
console.log("Using Web platform");
|
||||||
PlatformPeg.set(new WebPlatform());
|
PlatformPeg.set(new WebPlatform());
|
||||||
}
|
}
|
||||||
|
// Register service worker if available on this platform
|
||||||
|
PlatformPeg.get().registerServiceWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadConfig() {
|
export async function loadConfig() {
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||||||
return 'Web Platform'; // no translation required: only used for analytics
|
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
|
* Returns true if the platform supports displaying
|
||||||
* notifications, otherwise false.
|
* notifications, otherwise false.
|
||||||
|
|||||||
Reference in New Issue
Block a user