This commit is contained in:
2020-10-01 20:47:03 +00:00
parent ed48036105
commit 219cd91a19
7 changed files with 46 additions and 27 deletions

View File

@@ -275,18 +275,25 @@ export default {
//https://medium.com/@dougallrich/give-users-control-over-app-updates-in-vue-cli-3-pwas-20453aedc1f2
refreshing: false,
registration: null,
updateExists: true
updateExists: false
};
},
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;
this.refreshing = true;
window.location.reload();
});
async created() {
//Don't call this unless there is a service worker (https or localhost only, not private network) or else vuetify goes snakey and things start breaking
if (navigator.serviceWorker) {
//pwa update
//https://medium.com/@dougallrich/give-users-control-over-app-updates-in-vue-cli-3-pwas-20453aedc1f2
document.addEventListener("swUpdated", await this.showRefreshUI, {
once: true
});
//for the record, this is the breaking code if there is no serviceworker
navigator.serviceWorker.addEventListener("controllerchange", () => {
if (this.refreshing) return;
this.refreshing = true;
window.location.reload();
});
}
//Removed this when I added the PWA update code because in reality it should not be required for
//regular updates as it would be very intrusive, instead, on a new version it should internally fixup the
@@ -398,6 +405,9 @@ export default {
newNotificationCount() {
return this.$store.state.newNotificationCount;
},
test() {
alert("App.vue::test() method");
},
//PWA update
async showRefreshUI(e) {
this.registration = e.detail;

View File

@@ -1,4 +1,4 @@
export default {
version: "8.0.0-alpha.31",
version: "8.0.0-alpha.57",
copyright: "© 1999-2020, Ground Zero Tech-Works Inc."
};

View File

@@ -15,6 +15,7 @@ if (process.env.NODE_ENV === "production") {
},
updated(registration) {
console.log("New content is available; please refresh.");
//https://medium.com/@dougallrich/give-users-control-over-app-updates-in-vue-cli-3-pwas-20453aedc1f2
document.dispatchEvent(
new CustomEvent("swUpdated", { detail: registration })