aboutsummaryrefslogtreecommitdiff
path: root/src/components/ReloadPrompt.tsx
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-03-01 23:35:17 +0100
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-03-01 23:35:17 +0100
commitad202bd37273e67d98565405486675ca258b4f59 (patch)
treec877af39bd23200cf7091eed98719f8bffb91c8e /src/components/ReloadPrompt.tsx
parent400654b6b1c8a2f39482f7c60b41ec363d882af2 (diff)
downloadit-tools-ad202bd37273e67d98565405486675ca258b4f59.tar.gz
it-tools-ad202bd37273e67d98565405486675ca258b4f59.tar.zst
it-tools-ad202bd37273e67d98565405486675ca258b4f59.zip
revert(pwa): fallback to autoUpdate
Diffstat (limited to 'src/components/ReloadPrompt.tsx')
-rw-r--r--src/components/ReloadPrompt.tsx52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/components/ReloadPrompt.tsx b/src/components/ReloadPrompt.tsx
deleted file mode 100644
index 39ced27..0000000
--- a/src/components/ReloadPrompt.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/* eslint-disable vue/one-component-per-file */
-import { useRegisterSW } from 'virtual:pwa-register/vue';
-import { useNotification, type NotificationReactive } from 'naive-ui';
-import { defineComponent } from 'vue';
-import { whenever } from '@vueuse/core';
-
-export default defineComponent({
- setup() {
- const notificationBuilder = useNotification();
-
- const { needRefresh, offlineReady, updateServiceWorker } = useRegisterSW();
-
- let notification: NotificationReactive | null = null;
-
- const onUpdateClicked = () => {
- if (notification) {
- notification.action = () => (
- <n-button loading type="primary" secondary>
- Reloading
- </n-button>
- );
- }
-
- updateServiceWorker();
- };
-
- whenever(
- needRefresh,
- () => {
- notification = notificationBuilder.create({
- title: 'A new version is out!',
- content: 'Update to get the latest version of it-tools',
- closable: true,
- onClose: () => {
- needRefresh.value = false;
- return true;
- },
- action: () => (
- <n-button onClick={onUpdateClicked} type="primary" secondary>
- Reload
- </n-button>
- ),
- });
- },
- { immediate: true },
- );
-
- whenever(offlineReady, () => notification?.destroy(), { immediate: true });
-
- return () => '';
- },
-});