From 0bbcda09af8d1053ee57655e4df0909f42d2770f Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 15 Jan 2021 12:35:42 +0000 Subject: [PATCH] Move into constructor --- src/vector/init.tsx | 2 -- src/vector/platform/WebPlatform.ts | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vector/init.tsx b/src/vector/init.tsx index bb5e968c7c..de022622db 100644 --- a/src/vector/init.tsx +++ b/src/vector/init.tsx @@ -49,8 +49,6 @@ 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() { diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index 33e37edfe8..9f9f4a3995 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -34,16 +34,18 @@ const POKE_RATE_MS = 10 * 60 * 1000; // 10 min export default class WebPlatform extends VectorBasePlatform { private runningVersion: string = null; - getHumanReadableName(): string { - return 'Web Platform'; // no translation required: only used for analytics - } - - registerServiceWorker(): void { + constructor() { + super(); + // Register service worker if available on this platform if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js'); } } + getHumanReadableName(): string { + return 'Web Platform'; // no translation required: only used for analytics + } + /** * Returns true if the platform supports displaying * notifications, otherwise false.