summaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-11-28 15:05:55 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-11-28 15:05:55 +0900
commit607836331103cae089487e4d517f3de5c02ed1bc (patch)
tree94ebf18d04e203d6b4c70d809546980e0e76bd64 /src/web
parentFix bug (diff)
downloadmisskey-607836331103cae089487e4d517f3de5c02ed1bc.tar.gz
misskey-607836331103cae089487e4d517f3de5c02ed1bc.tar.bz2
misskey-607836331103cae089487e4d517f3de5c02ed1bc.zip
:v:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/app/boot.js27
-rw-r--r--src/web/app/common/scripts/api.ts3
-rw-r--r--src/web/app/init.ts4
3 files changed, 33 insertions, 1 deletions
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);
}
diff --git a/src/web/app/common/scripts/api.ts b/src/web/app/common/scripts/api.ts
index e62447b0a0..2008e6f5ac 100644
--- a/src/web/app/common/scripts/api.ts
+++ b/src/web/app/common/scripts/api.ts
@@ -29,7 +29,8 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => {
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, {
method: 'POST',
body: JSON.stringify(data),
- credentials: endpoint === 'signin' ? 'include' : 'omit'
+ credentials: endpoint === 'signin' ? 'include' : 'omit',
+ cache: 'no-cache'
}).then(res => {
if (--pending === 0) spinner.parentNode.removeChild(spinner);
if (res.status === 200) {
diff --git a/src/web/app/init.ts b/src/web/app/init.ts
index 79be1d3687..154b1ba0f0 100644
--- a/src/web/app/init.ts
+++ b/src/web/app/init.ts
@@ -19,6 +19,10 @@ require('./common/tags');
console.info(`Misskey v${_VERSION_} (葵 aoi)`);
+// BootTimer解除
+window.clearTimeout((window as any).mkBootTimer);
+delete (window as any).mkBootTimer;
+
if (_HOST_ != 'localhost') {
document.domain = _HOST_;
}