Skip to content

Commit

Permalink
Merge branch 'release/0.4.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Nov 29, 2019
2 parents c8c1ace + 146ad4d commit b606e21
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [0.4.6] - 2019-11-29
### Fixed
- Not update app using browser reload, to work properly when an update is available

## [0.4.5] - 2019-11-29
### Changed
- Update dependencies
Expand Down Expand Up @@ -87,7 +91,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
### Added
- First release

[Unreleased]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.5...HEAD
[Unreleased]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.6...HEAD
[0.4.6]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.5...v0.4.6
[0.4.5]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.4...v0.4.5
[0.4.4]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.3...v0.4.4
[0.4.3]: https://github.com/nwtgck/piping-ui-web/compare/v0.4.2...v0.4.3
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piping-ui",
"version": "0.4.5",
"version": "0.4.6",
"private": true,
"author": "Ryo Ota <[email protected]> (https://github.com/nwtgck)",
"scripts": {
Expand Down
31 changes: 22 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export default class App extends Vue {
mdiDotsVertical,
};
pwa: {refreshing: boolean, updateExists: boolean} = {
// TODO: Remove any
pwa: {refreshing: boolean, registration?: any, updateExists: boolean} = {
refreshing: false,
registration: undefined,
updateExists: false
};
private version = VERSION;
Expand All @@ -85,11 +87,7 @@ export default class App extends Vue {
created () {
document.addEventListener(
'swUpdated',
() => {
this.pwa.updateExists = true;
},
{ once: true },
'swUpdated', this.showRefreshUI, { once: true }
);
}
Expand All @@ -98,12 +96,27 @@ export default class App extends Vue {
this.$vuetify.theme.dark = enableDarkTheme();
}
// TODO: Remove any
showRefreshUI (e: any) {
this.pwa.registration = e.detail;
this.pwa.updateExists = true;
}
// Update PWA app
refreshApp () {
this.pwa.updateExists = false;
if (this.pwa.refreshing) return;
this.pwa.refreshing = true;
window.location.reload();
if (this.pwa.registration === undefined || !this.pwa.registration.waiting) {
return;
}
this.pwa.registration.waiting.postMessage('skipWaiting');
navigator.serviceWorker.addEventListener(
'controllerchange', () => {
if (this.pwa.refreshing) return;
this.pwa.refreshing = true;
window.location.reload();
},
{once: true}
);
}
}
</script>
Expand Down
11 changes: 2 additions & 9 deletions src/registerServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@ if (process.env.NODE_ENV === 'production') {
},
updated (registration) {
console.log('New content is available; please refresh.')
registration.waiting.postMessage('skipWaiting')
navigator.serviceWorker.addEventListener(
'controllerchange',
() => {
document.dispatchEvent(
new CustomEvent('swUpdated')
);
},
{once: true},
document.dispatchEvent(
new CustomEvent('swUpdated', { detail: registration })
);
},
offline () {
Expand Down

0 comments on commit b606e21

Please sign in to comment.