This commit is contained in:
@@ -10,11 +10,7 @@
|
||||
https://github.com/vuetifyjs/vuetify/issues/9607
|
||||
|
||||
-->
|
||||
<template>
|
||||
<button v-if="updateExists" @click="refreshApp">
|
||||
New version available! Click to update
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<v-navigation-drawer
|
||||
v-if="isAuthenticated"
|
||||
v-model="drawer"
|
||||
@@ -279,11 +275,12 @@ export default {
|
||||
//https://medium.com/@dougallrich/give-users-control-over-app-updates-in-vue-cli-3-pwas-20453aedc1f2
|
||||
refreshing: false,
|
||||
registration: null,
|
||||
updateExists: false
|
||||
updateExists: true
|
||||
};
|
||||
},
|
||||
created() {
|
||||
//pwa update
|
||||
//https://medium.com/@dougallrich/give-users-control-over-app-updates-in-vue-cli-3-pwas-20453aedc1f2
|
||||
document.addEventListener("swUpdated", this.showRefreshUI, { once: true });
|
||||
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
||||
if (this.refreshing) return;
|
||||
@@ -402,9 +399,24 @@ export default {
|
||||
return this.$store.state.newNotificationCount;
|
||||
},
|
||||
//PWA update
|
||||
showRefreshUI(e) {
|
||||
async showRefreshUI(e) {
|
||||
this.registration = e.detail;
|
||||
this.updateExists = true;
|
||||
|
||||
//Ok, if not logged in just force the update immediately
|
||||
if (!this.isAuthenticated) {
|
||||
this.refreshApp();
|
||||
return;
|
||||
}
|
||||
|
||||
//User is logged in offer to update in a dialog with translated text
|
||||
let dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||
"UpdateAvailable"
|
||||
);
|
||||
if (dialogResult == false) {
|
||||
return;
|
||||
}
|
||||
this.refreshApp();
|
||||
},
|
||||
refreshApp() {
|
||||
this.updateExists = false;
|
||||
|
||||
Reference in New Issue
Block a user