From 074b2a48eef723e5c4f1705c15f7a147e9d0bfbe Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 16 Apr 2018 15:59:43 +0900 Subject: [PATCH] Better recovery system --- locales/en.yml | 2 + locales/fr.yml | 2 + locales/ja.yml | 2 + src/client/app/boot.js | 34 ++-- .../connect-failed.troubleshooter.vue | 156 +++++++++--------- src/client/assets/flush.html | 16 ++ src/client/assets/recover.html | 28 ---- 7 files changed, 124 insertions(+), 116 deletions(-) create mode 100644 src/client/assets/flush.html delete mode 100644 src/client/assets/recover.html diff --git a/locales/en.yml b/locales/en.yml index 578681936..446ef371b 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -62,6 +62,8 @@ common/views/components/connect-failed.troubleshooter.vue: no-server-desc: "The network connection of your PC is normal, but you could not connect to Misskey's server. There is a possibility that the server is either down or under maintenance, please try again later." success: "Successfully connected to Misskey's server" success-desc: "It seems to be able to connect. Please reload the page." + flush: "Clean cache" + set-version: "Specify version" common/views/components/messaging.vue: search-user: "Find an user" diff --git a/locales/fr.yml b/locales/fr.yml index 4af300fcf..583104b4f 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -62,6 +62,8 @@ common/views/components/connect-failed.troubleshooter.vue: no-server-desc: "Votre connexion est OK, mais il a été impossible de vous connecter au serveur de Misskey. Il y a des chances que le serveur soit hors-ligne ou en maintenance, veuillez ressayer plus tard." success: "Connexion au serveur de Misskey reussie!" success-desc: "La connexion au serveur a été reussie. Veuillez recharger la page." + flush: "キャッシュの削除" + set-version: "バージョン指定" common/views/components/messaging.vue: search-user: "Trouver un utilisateur" diff --git a/locales/ja.yml b/locales/ja.yml index 1f70f4203..b5479b5ce 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -62,6 +62,8 @@ common/views/components/connect-failed.troubleshooter.vue: no-server-desc: "お使いのPCのインターネット接続は正常ですが、Misskeyのサーバーには接続できませんでした。サーバーがダウンまたはメンテナンスしている可能性があるので、しばらくしてから再度御アクセスください。" success: "Misskeyのサーバーに接続できました" success-desc: "正常に接続できるようです。ページを再度読み込みしてください。" + flush: "キャッシュの削除" + set-version: "バージョン指定" common/views/components/messaging.vue: search-user: "ユーザーを探す" diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 12b0d220a..a0709842b 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -18,6 +18,8 @@ // ブロック内に入れてスコープを非グローバル化するとそれが防げます // (Chrome以外のブラウザでは検証していません) { + if (localStorage.getItem('shouldFlush') == 'true') refresh(); + // Get the current url information const url = new URL(location.href); @@ -103,19 +105,25 @@ '\n\n' + 'New version of Misskey available. The page will be reloaded.'); - // Clear cache (serive worker) - try { - navigator.serviceWorker.controller.postMessage('clear'); - - navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(registration => registration.unregister()); - }); - } catch (e) { - console.error(e); - } - - // Force reload - location.reload(true); + refresh(); } }, 3000); + + function refresh() { + localStorage.setItem('shouldFlush', 'false'); + + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + + navigator.serviceWorker.getRegistrations().then(registrations => { + registrations.forEach(registration => registration.unregister()); + }); + } catch (e) { + console.error(e); + } + + // Force reload + location.reload(true); + } } diff --git a/src/client/app/common/views/components/connect-failed.troubleshooter.vue b/src/client/app/common/views/components/connect-failed.troubleshooter.vue index fffabe5a3..2ee5f67c8 100644 --- a/src/client/app/common/views/components/connect-failed.troubleshooter.vue +++ b/src/client/app/common/views/components/connect-failed.troubleshooter.vue @@ -1,34 +1,39 @@ @@ -77,61 +82,62 @@ export default Vue.extend({ diff --git a/src/client/assets/flush.html b/src/client/assets/flush.html new file mode 100644 index 000000000..d43600157 --- /dev/null +++ b/src/client/assets/flush.html @@ -0,0 +1,16 @@ + + + + + + Misskeyのリカバリ + + + diff --git a/src/client/assets/recover.html b/src/client/assets/recover.html deleted file mode 100644 index b1889c72e..000000000 --- a/src/client/assets/recover.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - Misskeyのリカバリ - - -