-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWA first commit #404
PWA first commit #404
Conversation
console.log('New content is available; please refresh.') | ||
let confirmationResult = confirm('New content found! Do you want to reload the app?') | ||
if (confirmationResult) { registration.waiting.postMessage({ action: 'skipWaiting' }) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer 'if' blocks to be on a separate line unless it's really short (like the return on line 37 below, which is ok!).
In fact, I think you'll get a lint error because your have the { } block on the same line as the if.
@@ -29,4 +31,11 @@ if (process.env.NODE_ENV === 'production') { | |||
console.error('Error during service worker registration:', error) | |||
} | |||
}) | |||
|
|||
let refreshing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably initialize this to false.
workbox.precaching.suppressWarnings() | ||
workbox.precaching.precacheAndRoute(self.__precacheManifest, {}) | ||
|
||
// install new service worker when ok, then reload page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment I wrote in https://github.com/severinbeauvais/lear/blob/1225/coops-ui/src/service-worker.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to merge.
Issue #: /bcgov/entity#1225
Description of changes:
Created custom service worker
Updated the register service worker to show the confirmation pop up and post the message to the service worker. Added call back to force reload the window once user confirms to update the app.
Updated the vue config to point to custom service worker
Note : This commit is to test whether the confirmation popup is displayed when a new version of the app is available. May need a few iterations to get this working
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the lear license (Apache 2.0).