This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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."
|
||||
};
|
||||
|
||||
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user