iceshrimp/src/server/web/views/flush.pug

39 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-02-09 12:47:50 +09:00
doctype html
html
#msg
2020-02-09 12:47:50 +09:00
script.
const msg = document.getElementById('msg');
2020-02-09 12:47:50 +09:00
try {
localStorage.clear();
message('localStorage cleared');
2020-02-09 12:47:50 +09:00
const delidb = indexedDB.deleteDatabase('MisskeyClient');
delidb.onsuccess = () => message('indexedDB cleared');
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage('clear');
navigator.serviceWorker.getRegistrations()
.then(registrations => {
return Promise.all(registrations.map(registration => registration.unregister()));
})
.then(() => {
message('Success Flush! Please reopen Misskey.\n成功しました。Misskeyを開き直してください。');
})
.catch(e => { throw Error(e) });
} else {
message('Success Flush! Please reopen Misskey.\n成功しました。Misskeyを開き直してください。');
}
2020-02-09 12:47:50 +09:00
} catch (e) {
console.error(e);
message(`${e}¥n¥nFlush Failed. Please reopen Misskey.\n失敗しました。Misskeyを開き直してください。`);
2020-02-09 12:47:50 +09:00
setTimeout(() => {
location = '/';
}, 10000)
}
function message(text) {
msg.insertAdjacentHTML('beforeend', `<p>[${(new Date()).toString()}] ${text.replace(/¥n/g,'<br>')}</p>`)
}