This commit is contained in:
syuilo 2017-11-28 15:41:41 +09:00
parent 10c943d28a
commit 305a620aed
4 changed files with 22 additions and 0 deletions

View file

@ -92,6 +92,13 @@
'\n\n' + '\n\n' +
'New version of Misskey available. The page will be reloaded.'); 'New version of Misskey available. The page will be reloaded.');
// Clear cache (serive worker)
try {
navigator.serviceWorker.controller.postMessage('clear');
} catch (e) {
console.error(e);
}
// Force reload // Force reload
location.reload(true); location.reload(true);
} }

View file

@ -63,3 +63,9 @@ self.addEventListener('push', ev => {
}); });
})); }));
}); });
self.addEventListener('message', ev => {
if (ev.data == 'clear') {
caches.keys().then(keys => keys.forEach(key => caches.delete(key)));
}
});

8
src/web/assets/help.js Normal file
View file

@ -0,0 +1,8 @@
const yn = window.confirm(
'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか');
if (yn) {
location.reload(true);
} else {
alert('問題が解決しない場合はサーバー管理者までお問い合せください。');
}

View file

@ -39,6 +39,7 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets
app.use('/assets', express.static(`${__dirname}/assets`, { app.use('/assets', express.static(`${__dirname}/assets`, {
maxAge: ms('7 days') maxAge: ms('7 days')
})); }));
app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/help.js`));
app.use('/assets', (req, res) => { app.use('/assets', (req, res) => {
res.sendStatus(404); res.sendStatus(404);
}); });