From cd8949b425e98b451d8104252d9e09011c1ec81e Mon Sep 17 00:00:00 2001 From: Ronan Gaillard Date: Thu, 5 Nov 2020 19:25:17 +0100 Subject: [PATCH] fix: no update checking in browser --- src/js/check-updates.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/check-updates.js b/src/js/check-updates.js index 078e8c97..f45ee225 100644 --- a/src/js/check-updates.js +++ b/src/js/check-updates.js @@ -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 @@ -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') + } })