This commit is contained in:
syuilo 2017-11-28 15:05:55 +09:00
parent 5f4f046cd6
commit 6078363311
3 changed files with 33 additions and 1 deletions

View file

@ -69,4 +69,31 @@
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);
// 1秒経ってもスクリプトがロードされない場合はバージョンが古くて
// 404になっているせいかもしれないので、バージョンを確認して古ければ更新する
//
// 読み込まれたスクリプトからこのタイマーを解除できるように、
// グローバルにタイマーIDを代入しておく
window.mkBootTimer = window.setTimeout(async () => {
// Fetch meta
const res = await fetch(API + '/meta', {
method: 'POST',
cache: 'no-cache'
});
// Parse
const meta = await res.json();
// Compare versions
if (meta.version != VERSION) {
alert(
'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' +
'\n\n' +
'New version of Misskey available. The page will be reloaded.');
// Force reload
location.reload(true);
}
}, 1000);
}