Move service worker into platform

pull/16157/head
J. Ryan Stinnett 2 years ago
parent 87e67d8168
commit e077d9ca5f
  1. 5
      src/vector/index.ts
  2. 2
      src/vector/init.tsx
  3. 6
      src/vector/platform/WebPlatform.ts

@ -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…
Cancel
Save