Skip to content

Commit

Permalink
Disable dialog for purge caches & Re-order buttons
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Aug 27, 2023
1 parent 54e5372 commit 013b23f
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions bundles/org.openhab.ui/web/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
<f7-list-button color="blue" @click="loadData">
{{ $t('dialogs.retry') }}
</f7-list-button>
<f7-list-button color="red" @click="purgeServiceWorkerAndCaches">
{{ $t('about.reload.purgeCachesAndRefresh') }}
</f7-list-button>
<f7-list-button color="blue" @click="reload">
{{ $t('about.reload.reloadApp') }}
</f7-list-button>
<f7-list-button color="red" @click="purgeServiceWorkerAndCaches">
{{ $t('about.reload.purgeCachesAndRefresh') }}
</f7-list-button>
</f7-list>
</f7-block>

Expand Down Expand Up @@ -712,35 +712,30 @@ export default {
return toast
},
purgeServiceWorkerAndCaches () {
this.$f7.dialog.confirm(
this.$t('about.reload.confirmPurge'),
() => {
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
registration.unregister().then(function () {
return self.clients.matchAll()
}).then(function (clients) {
clients.forEach(client => {
if (client.url && 'navigate' in client) {
setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000)
}
})
})
}
})
window.caches.keys().then(function (cachesNames) {
console.log('Deleting caches')
return Promise.all(cachesNames.map(function (cacheName) {
return caches.delete(cacheName).then(function () {
console.log('Cache with name ' + cacheName + ' is deleted')
})
}))
}).then(function () {
console.log('Caches deleted')
setTimeout(() => { location.reload(true) }, 1000)
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (let registration of registrations) {
registration.unregister().then(function () {
return self.clients.matchAll()
}).then(function (clients) {
clients.forEach(client => {
if (client.url && 'navigate' in client) {
setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000)
}
})
})
}
)
})
window.caches.keys().then(function (cachesNames) {
console.log('Deleting caches')
return Promise.all(cachesNames.map(function (cacheName) {
return caches.delete(cacheName).then(function () {
console.log('Cache with name ' + cacheName + ' is deleted')
})
}))
}).then(function () {
console.log('Caches deleted')
setTimeout(() => { location.reload(true) }, 1000)
})
},
reload () {
document.location.reload()
Expand Down

0 comments on commit 013b23f

Please sign in to comment.