From 607836331103cae089487e4d517f3de5c02ed1bc Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:05:55 +0900 Subject: :v: --- src/web/app/boot.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/web/app/boot.js') diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 4a8ea030a1..a5f0e04d31 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -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); } -- cgit v1.3.1-freya