From 8e9bd0bbd53e707fe4c6679a359a2caeb914e3ad Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Mar 2020 22:49:42 +0900 Subject: [PATCH] Fix dark mode sync bug --- src/client/init.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/client/init.ts b/src/client/init.ts index b9c6aedae..1fcd97190 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -145,6 +145,12 @@ os.init(async () => { } }, false) + os.store.watch(state => state.device.darkMode, darkMode => { + // TODO: このファイルでbuiltinThemesを参照するとcode splittingが効かず、初回読み込み時に全てのテーマコードを読み込むことになってしまい無駄なので何とかする + const themes = builtinThemes.concat(os.store.state.device.themes); + applyTheme(themes.find(x => x.id === (darkMode ? os.store.state.device.darkTheme : os.store.state.device.lightTheme))); + }); + //#region Sync dark mode if (os.store.state.device.syncDeviceDarkMode) { os.store.commit('device/set', { key: 'darkMode', value: isDeviceDarkmode() }); @@ -176,13 +182,6 @@ os.init(async () => { isMobile: isMobile }; }, - watch: { - '$store.state.device.darkMode'() { - // TODO: このファイルでbuiltinThemesを参照するとcode splittingが効かず、初回読み込み時に全てのテーマコードを読み込むことになってしまい無駄なので何とかする - const themes = builtinThemes.concat(this.$store.state.device.themes); - applyTheme(themes.find(x => x.id === (this.$store.state.device.darkMode ? this.$store.state.device.darkTheme : this.$store.state.device.lightTheme))); - } - }, methods: { api: os.api, signout: os.signout,