From 8c0ee7656c112d21f3a6c452780fcb4ab9c99e1a Mon Sep 17 00:00:00 2001 From: Anssi Juvonen Date: Wed, 11 Sep 2024 16:04:39 +0300 Subject: [PATCH] Fix auto updates --- src/App.vue | 14 ++++++++------ src/i18n/en.json | 3 +-- src/i18n/fi.json | 3 +-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9c0a720..907d59c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,8 +9,6 @@ import {useAppStateStore} from '@/stores/appStateStore'; import NavBar from '@/components/NavBar.vue'; import ToastContainer from '@/components/ToastContainer.vue'; -const {addToastMessage} = useAppStateStore(); - const {t, locale} = useI18n(); const route = useRoute(); @@ -20,10 +18,14 @@ const {settings} = storeToRefs(useAppStateStore()); const {updateServiceWorker} = useRegisterSW({ immediate: true, - async onNeedRefresh() { - addToastMessage(t('general.updateReady')); - await updateServiceWorker(); - window.location.reload(); + onRegisteredSW(_, registration) { + registration && + setInterval(() => { + registration.update(); + }, 60 * 1000); + }, + onNeedRefresh() { + updateServiceWorker(); }, }); diff --git a/src/i18n/en.json b/src/i18n/en.json index abcc667..c238143 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -106,8 +106,7 @@ "clickToAdd": "Add {0}", "clickToRemove": "Remove {0}", "close": "Close", - "start": "Start", - "updateReady": "The app has been updated with latest content." + "start": "Start" }, "home": { "info": "Learn more", diff --git a/src/i18n/fi.json b/src/i18n/fi.json index 5e6e6e6..db0b2dc 100644 --- a/src/i18n/fi.json +++ b/src/i18n/fi.json @@ -106,8 +106,7 @@ "clickToAdd": "Lisää {0}", "clickToRemove": "Poista {0}", "close": "Sulje", - "start": "Aloita", - "updateReady": "Sovellus on päivitetty uuteen versioon." + "start": "Aloita" }, "home": { "info": "Lue lisää",