Add prompt to reload page if new version came out
This commit is contained in:
parent
a0a290e06c
commit
40432a9717
@ -34,6 +34,7 @@
|
||||
"xpath": "^0.0.27"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/workbox-window": "^4.3.3",
|
||||
"babel-minify-webpack-plugin": "^0.3.1",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"copy-webpack-plugin": "^4.5.2",
|
||||
@ -42,6 +43,7 @@
|
||||
"vue2-leaflet": "^1.0.2",
|
||||
"vuex": "^3.0.1",
|
||||
"vuex-class": "^0.3.1",
|
||||
"workbox-webpack-plugin": "^4.3.1"
|
||||
"workbox-webpack-plugin": "^4.3.1",
|
||||
"workbox-window": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ window['Popper'] = Popper;
|
||||
// dependencies
|
||||
import Vue from "vue";
|
||||
import Vuex, { mapActions, mapMutations, mapState, Store } from 'vuex';
|
||||
import { Workbox } from "workbox-window";
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
@ -38,8 +39,18 @@ Vue.use(Vuex);
|
||||
store.dispatch('load', window['czydojade'].state);
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function() {
|
||||
navigator.serviceWorker.register('/service-worker.js');
|
||||
const wb = new Workbox("/service-worker.js");
|
||||
|
||||
wb.addEventListener('waiting', event => {
|
||||
if (window.confirm("Dostępna jest nowa wersja, przeładować?")) {
|
||||
wb.addEventListener('controlling', event => {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
wb.messageSW({type: 'SKIP_WAITING'});
|
||||
}
|
||||
});
|
||||
|
||||
wb.register();
|
||||
}
|
||||
})();
|
||||
|
@ -268,6 +268,11 @@
|
||||
"@types/webpack-sources" "*"
|
||||
source-map "^0.6.0"
|
||||
|
||||
"@types/workbox-window@^4.3.3":
|
||||
version "4.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/workbox-window/-/workbox-window-4.3.3.tgz#47f91df7ce7eea5c151a6beb3e8398c7db8ee538"
|
||||
integrity sha512-iIq2obSq3gvzhwFxg+/02v4VqfHjRg9hpEjoM68TKYcmCAe9QGlFsJ5qPZkJKUuZDVW7cUoR3iiA2jIALFU6Ag==
|
||||
|
||||
"@webassemblyjs/ast@1.8.5":
|
||||
version "1.8.5"
|
||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
|
||||
|
Loading…
Reference in New Issue
Block a user