From 6a3e6b0cd48dfc0cb865d4c86401f4733d71ff27 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:40:35 -0400 Subject: [PATCH] fix: Make changes as per review comments --- app.vue | 14 ++++++-------- nuxt.config.ts | 7 ------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app.vue b/app.vue index c76fc320..ba7d7edc 100644 --- a/app.vue +++ b/app.vue @@ -23,6 +23,11 @@ const { cacheValue } = useCache() const { currencyList } = storeToRefs(useCurrencyStore()) const { initProvider, reconnect } = useWalletConnectProvider() const { formatMessage } = useIntl() +const swHasUpgrade = ref(false) + +// Make the service worker update available to the rest of the app +// any view can use inject('swHasUpgrade') to access this value +provide('swHasUpgrade', swHasUpgrade) const setupTranslations = () => { useIntl().setupIntl(defaultConfig) @@ -217,7 +222,6 @@ useHead({ }), }, }) -const hasUpgrade = ref(false) if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').then(registration => { // Listen for updates @@ -226,19 +230,13 @@ if ('serviceWorker' in navigator) { if (newWorker) { newWorker.addEventListener('statechange', () => { if (newWorker.state === 'activated') { - // Notify the user that an update is available - console.log('A new version is available. Please refresh.') - hasUpgrade.value = true - // Optionally, prompt the user for a refresh, or defer it to a better time. + swHasUpgrade.value = true } }) } }) }) } -// Make the service worker update available to the rest of the app -// any view can use -provide('swHasUpgrade', hasUpgrade)