Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
fix: Make changes as per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
richtera committed Oct 31, 2024
1 parent 0e73481 commit 6a3e6b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
14 changes: 6 additions & 8 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const { cacheValue } = useCache()
const { currencyList } = storeToRefs(useCurrencyStore())
const { initProvider, reconnect } = useWalletConnectProvider()
const { formatMessage } = useIntl()
const swHasUpgrade = ref<boolean>(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)
Expand Down Expand Up @@ -217,7 +222,6 @@ useHead({
}),
},
})
const hasUpgrade = ref<boolean>(false)
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(registration => {
// Listen for updates
Expand All @@ -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)
</script>

<template>
Expand Down
7 changes: 0 additions & 7 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,6 @@ export default defineNuxtConfig({
injectManifest: {
globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
},
// We don't actually use the client stub at all.
// client: {
// installPrompt: true,
// // you don't need to include this: only for testing purposes
// // if enabling periodic sync for update use 1 hour or so (periodicSyncForUpdates: 3600)
// // periodicSyncForUpdates: 20,
// },
resolve: {
alias: {
process: 'process/browser',
Expand Down

0 comments on commit 6a3e6b0

Please sign in to comment.