From 4363f625025edeb19fb480a00e2e3b460c6091a9 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 9 Jul 2023 01:48:34 +0800 Subject: Remove service worker. --- FrontEnd/src/index.tsx | 1 - FrontEnd/src/service-worker.tsx | 105 ---------------------------------------- FrontEnd/src/sw.ts | 64 ------------------------ 3 files changed, 170 deletions(-) delete mode 100644 FrontEnd/src/service-worker.tsx delete mode 100644 FrontEnd/src/sw.ts (limited to 'FrontEnd/src') diff --git a/FrontEnd/src/index.tsx b/FrontEnd/src/index.tsx index 2affb277..f14cfa8e 100644 --- a/FrontEnd/src/index.tsx +++ b/FrontEnd/src/index.tsx @@ -1,7 +1,6 @@ import "regenerator-runtime"; import "core-js/modules/es.promise"; import "core-js/modules/es.array.iterator"; -import "pepjs"; import React from "react"; import { createRoot } from "react-dom/client"; diff --git a/FrontEnd/src/service-worker.tsx b/FrontEnd/src/service-worker.tsx deleted file mode 100644 index e4af54e1..00000000 --- a/FrontEnd/src/service-worker.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import React from "react"; -import { useTranslation } from "react-i18next"; - -import { pushAlert } from "./services/alert"; - -import Button from "./views/common/button/Button"; - -if (import.meta.env.PROD && "serviceWorker" in navigator) { - let isThisTriggerUpgrade = false; - - const upgradeSuccessLocalStorageKey = "TIMELINE_UPGRADE_SUCCESS"; - - if (window.localStorage.getItem(upgradeSuccessLocalStorageKey)) { - pushAlert({ - message: "serviceWorker.upgradeSuccess", - type: "success", - }); - window.localStorage.removeItem(upgradeSuccessLocalStorageKey); - } - - void import("workbox-window").then(({ Workbox, messageSW }) => { - const wb = new Workbox("/sw.js"); - let registration: ServiceWorkerRegistration | undefined; - - // externalactivated is not usable but I still use its name. - wb.addEventListener("controlling", () => { - const upgradeReload = (): void => { - window.localStorage.setItem(upgradeSuccessLocalStorageKey, "true"); - window.location.reload(); - }; - - if (isThisTriggerUpgrade) { - upgradeReload(); - } else { - const Message: React.FC = () => { - const { t } = useTranslation(); - return ( - <> - {t("serviceWorker.externalActivatedPrompt")} -