From 0e6bff709af16d6196b5cef17cc8a8f69af97cca Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sat, 19 Dec 2020 20:58:56 +0800
Subject: fix: Fix code to adapt breaking change in workbox.

---
 FrontEnd/src/app/service-worker.tsx | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

(limited to 'FrontEnd/src/app/service-worker.tsx')

diff --git a/FrontEnd/src/app/service-worker.tsx b/FrontEnd/src/app/service-worker.tsx
index 3be54bc1..2dc7fb6e 100644
--- a/FrontEnd/src/app/service-worker.tsx
+++ b/FrontEnd/src/app/service-worker.tsx
@@ -70,7 +70,9 @@ if ("serviceWorker" in navigator) {
       }
     });
 
-    const showSkipWaitingPrompt = (): void => {
+    // Add an event listener to detect when the registered
+    // service worker has installed but is waiting to activate.
+    wb.addEventListener("waiting", (): void => {
       const upgrade = (): void => {
         isThisTriggerUpgrade = true;
         if (registration && registration.waiting) {
@@ -99,12 +101,7 @@ if ("serviceWorker" in navigator) {
         dismissTime: "never",
         type: "success",
       });
-    };
-
-    // Add an event listener to detect when the registered
-    // service worker has installed but is waiting to activate.
-    wb.addEventListener("waiting", showSkipWaitingPrompt);
-    wb.addEventListener("externalwaiting", showSkipWaitingPrompt);
+    });
 
     void wb.register().then((reg) => {
       registration = reg;
-- 
cgit v1.2.3

