From c88ea7150c79cffa192a74d57cea0b39a0f82555 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Thu, 12 Aug 2021 12:02:41 +0900
Subject: [PATCH] =?UTF-8?q?fix(client):=20=E6=9B=B4=E6=96=B0=E6=99=82?=
 =?UTF-8?q?=E3=81=AB=E3=83=86=E3=83=BC=E3=83=9E=E3=82=AD=E3=83=A3=E3=83=83?=
 =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=82=92=E3=82=AF=E3=83=AA=E3=82=A2=E3=81=99?=
 =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGELOG.md       |  3 +++
 src/client/init.ts | 15 ++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 71253df363..c6eb7daaca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,9 @@
 - Docker: Node.jsを16.6.2に
 - 依存関係の更新
 
+### Bugfixes
+- Misskey更新時、テーマキャッシュの影響でスタイルがおかしくなる問題を修正
+
 ## 12.86.0 (2021/08/11)
 
 ### Improvements
diff --git a/src/client/init.ts b/src/client/init.ts
index a4a228da22..95aa18862c 100644
--- a/src/client/init.ts
+++ b/src/client/init.ts
@@ -16,7 +16,7 @@ import { router } from '@client/router';
 import { applyTheme } from '@client/scripts/theme';
 import { isDeviceDarkmode } from '@client/scripts/is-device-darkmode';
 import { i18n } from '@client/i18n';
-import { stream, dialog, post } from '@client/os';
+import { stream, dialog, post, popup } from '@client/os';
 import * as sound from '@client/scripts/sound';
 import { $i, refreshAccount, login, updateAccount, signout } from '@client/account';
 import { defaultStore, ColdDeviceStorage } from '@client/store';
@@ -198,6 +198,19 @@ if (splash) {
 	splash.style.pointerEvents = 'none';
 }
 
+// クライアントが更新されたか?
+const lastVersion = localStorage.getItem('lastVersion');
+if (lastVersion !== version) {
+	localStorage.setItem('lastVersion', version);
+
+	// テーマリビルドするため
+	localStorage.removeItem('theme');
+
+	// TODO: バージョンが新しくなった時だけダイアログ出す
+	//popup();
+}
+
+// NOTE: この処理は必ず↑のクライアント更新時処理より後に来ること(テーマ再構築のため)
 watch(defaultStore.reactiveState.darkMode, (darkMode) => {
 	applyTheme(darkMode ? ColdDeviceStorage.get('darkTheme') : ColdDeviceStorage.get('lightTheme'));
 }, { immediate: localStorage.theme == null });