Skip to content
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

Merged
merged 1 commit into from
Oct 16, 2019
Merged

PWA first commit #404

merged 1 commit into from
Oct 16, 2019

Conversation

lmallika86
Copy link
Contributor

@lmallika86 lmallika86 commented Oct 16, 2019

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).

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' }) }
Copy link
Collaborator

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
Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@severinbeauvais severinbeauvais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to merge.

@lmallika86 lmallika86 merged commit 21502e5 into bcgov:master Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants