Skip to content

Commit

Permalink
Add removal of PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekiwaniuk committed Nov 10, 2024
1 parent dcbb5dc commit b6b2cb5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/apps/portfolio
git pull
git pull --rebase
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml down
docker compose -f docker-compose.prod.yml up -d
33 changes: 33 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,39 @@ onMounted(() => {
updateLangAttribute();
updateBackgroundColorOnScrollbar();
// remove service worker and deregister it, delete cache on all browsers
if (window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (const registration of registrations) {
console.log('unregister');
registration.unregister()
}
})
}
if ('caches' in window) {
caches.keys().then(function (keyList) {
return Promise.all(
keyList.map(function (key) {
console.log(`remove ${key}`)
return caches.delete(key)
})
)
})
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (const registration of registrations) {
// unregister service worker
console.log('serviceWorker unregistered')
registration.unregister()
setTimeout(function () {
console.log('trying redirect do')
window.location.replace(window.location.href) // because without redirecting, first time on page load: still service worker will be available
}, 3000)
}
})
}
const img = useImage();
const loadBackgroundImage = computed(() => {
const imgUrl = img('/img/background.png', {
Expand Down

0 comments on commit b6b2cb5

Please sign in to comment.