diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-16 15:59:43 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-16 15:59:43 +0900 |
| commit | 172cca6ad6fe73d00686d0355bde264c6340958e (patch) | |
| tree | dff22c58b7cb35d7c01b155f9d76de7446c3ca7a /src/client/app/boot.js | |
| parent | Fix bug (diff) | |
| download | misskey-172cca6ad6fe73d00686d0355bde264c6340958e.tar.gz misskey-172cca6ad6fe73d00686d0355bde264c6340958e.tar.bz2 misskey-172cca6ad6fe73d00686d0355bde264c6340958e.zip | |
Better recovery system
Diffstat (limited to 'src/client/app/boot.js')
| -rw-r--r-- | src/client/app/boot.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 12b0d220a9..a0709842b9 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -18,6 +18,8 @@ // ブロック内に入れてスコープを非グローバル化するとそれが防げます // (Chrome以外のブラウザでは検証していません) { + if (localStorage.getItem('shouldFlush') == 'true') refresh(); + // Get the current url information const url = new URL(location.href); @@ -103,19 +105,25 @@ '\n\n' + 'New version of Misskey available. The page will be reloaded.'); - // Clear cache (serive worker) - try { - navigator.serviceWorker.controller.postMessage('clear'); + refresh(); + } + }, 3000); + + function refresh() { + localStorage.setItem('shouldFlush', 'false'); - navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(registration => registration.unregister()); - }); - } catch (e) { - console.error(e); - } + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); - // Force reload - location.reload(true); + navigator.serviceWorker.getRegistrations().then(registrations => { + registrations.forEach(registration => registration.unregister()); + }); + } catch (e) { + console.error(e); } - }, 3000); + + // Force reload + location.reload(true); + } } |