From 9bd586d89ce135576d226eef5a3d638b02b20728 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Thu, 18 Jun 2020 13:54:09 +0200 Subject: [PATCH] Move service worker to ts file --- index.html | 16 ---------------- src/index.ts | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 61c0231..b4f46f2 100644 --- a/index.html +++ b/index.html @@ -53,21 +53,5 @@

JavaScript support is required to run this app.

- diff --git a/src/index.ts b/src/index.ts index 1ed2daa..c888890 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,3 +12,15 @@ const defaultTabs = [ defaultTabs.forEach((tab) => { manager.openTab(tab.page, tab.active); }); + +if ("serviceWorker" in navigator) { + const x = "sw.js"; + navigator.serviceWorker + .register(x) + .then((registration) => { + console.log("Registration successful, scope is:", registration.scope); + }) + .catch((error) => { + console.log("Service worker registration failed, error:", error); + }); +}