aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-19 20:58:56 +0800
committercrupest <crupest@outlook.com>2020-12-19 20:58:56 +0800
commit0e6bff709af16d6196b5cef17cc8a8f69af97cca (patch)
treea909fd448a424365b1cc6543063b178903e79d9d
parentc3d50bb41db76001c367addcdda87db5d019a58e (diff)
downloadtimeline-0e6bff709af16d6196b5cef17cc8a8f69af97cca.tar.gz
timeline-0e6bff709af16d6196b5cef17cc8a8f69af97cca.tar.bz2
timeline-0e6bff709af16d6196b5cef17cc8a8f69af97cca.zip
fix: Fix code to adapt breaking change in workbox.
-rw-r--r--FrontEnd/src/app/service-worker.tsx11
1 files changed, 4 insertions, 7 deletions
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;