diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 3de9eb3..dce6cda 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -16,6 +16,15 @@ +
+

+ A new version is available. Refresh to load it? +

+
+ + +
+
@@ -26,6 +35,7 @@ export default { name: 'App', data: () => ({ isConnected: false, + c: false, }), computed: { }, @@ -48,12 +58,23 @@ export default { methods: { storeLangPref() { localStorage.setItem('lang', this.$i18n.locale) + }, + async update() { + this.showUpdateUI = false; + await this.$workbox.messageSW({ type: "SKIP_WAITING" }); } }, mounted() { if (localStorage.getItem('lang')) this.$i18n.locale = localStorage.getItem('lang') }, + created() { + if (this.$workbox) { + this.$workbox.addEventListener("waiting", () => { + this.showUpdateUI = true; + }); + } + } } diff --git a/frontend/src/registerServiceWorker.js b/frontend/src/registerServiceWorker.js index 95c424e..837d167 100644 --- a/frontend/src/registerServiceWorker.js +++ b/frontend/src/registerServiceWorker.js @@ -3,15 +3,15 @@ import { Workbox } from "workbox-window"; let wb; if ("serviceWorker" in navigator) { - wb = new Workbox(`${process.env.BASE_URL}service-worker.js`); + wb = new Workbox(`${process.env.BASE_URL}service-worker.js`); - wb.addEventListener("controlling", () => { - window.location.reload(); - }); + wb.addEventListener("controlling", () => { + window.location.reload(); + }); - wb.register(); + wb.register(); } else { - wb = null; + wb = null; } export default wb; \ No newline at end of file