Skip to content

Commit

Permalink
fix: no update checking in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ronangaillard committed Nov 5, 2020
1 parent 1b8d795 commit cd8949b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/js/check-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const path = window.location.pathname
const swName = `${window.location}sw.js`

window.isUpdateAvailable = new Promise(function (resolve, reject) {
// we should not check for updates if app runs in browser
if (window.matchMedia('(display-mode: browser)').matches) {
resolve(false);
}
// lazy way of disabling service workers while developing
if ('serviceWorker' in navigator) {
navigator.serviceWorker
Expand Down Expand Up @@ -32,6 +36,8 @@ window.isUpdateAvailable = new Promise(function (resolve, reject) {
})

window.isUpdateAvailable.then((isAvailable) => {
$('#reload-btn').addEventListener('click', () => window.location.reload())
$('#update-alert').classList.remove('d-none')
if(isAvailable) {
$('#reload-btn').addEventListener('click', () => window.location.reload())
$('#update-alert').classList.remove('d-none')
}
})

0 comments on commit cd8949b

Please sign in to comment.