diff options
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/frontend/src/boot/common.ts | 10 | ||||
| -rw-r--r-- | packages/frontend/src/theme.ts | 7 |
2 files changed, 4 insertions, 13 deletions
diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 4becf32ab5..95ba278ff4 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -176,7 +176,7 @@ export async function common(createVue: () => Promise<App<Element>>) { })(); applyTheme(theme); - }, { immediate: isSafeMode || miLocalStorage.getItem('theme') == null }); + }, { immediate: true }); window.document.documentElement.dataset.colorScheme = store.s.darkMode ? 'dark' : 'light'; @@ -195,14 +195,6 @@ export async function common(createVue: () => Promise<App<Element>>) { applyTheme(theme ?? defaultLightTheme); } }); - } - - if (!isSafeMode) { - if (prefer.s.darkTheme && store.s.darkMode) { - if (miLocalStorage.getItem('themeId') !== prefer.s.darkTheme.id) applyTheme(prefer.s.darkTheme); - } else if (prefer.s.lightTheme && !store.s.darkMode) { - if (miLocalStorage.getItem('themeId') !== prefer.s.lightTheme.id) applyTheme(prefer.s.lightTheme); - } fetchInstanceMetaPromise.then(() => { // TODO: instance.defaultLightTheme/instance.defaultDarkThemeが不正な形式だった場合のケア diff --git a/packages/frontend/src/theme.ts b/packages/frontend/src/theme.ts index 4d03b1d0e9..7cbaf87243 100644 --- a/packages/frontend/src/theme.ts +++ b/packages/frontend/src/theme.ts @@ -131,7 +131,7 @@ function applyThemeInternal(theme: Theme, persist: boolean) { } let timeout: number | null = null; -let currentTheme: Theme | null = null; +let currentThemeId = miLocalStorage.getItem('themeId'); export function applyTheme(theme: Theme, persist = true) { if (timeout) { @@ -139,9 +139,8 @@ export function applyTheme(theme: Theme, persist = true) { timeout = null; } - if (deepEqual(currentTheme, theme)) return; - // リアクティビティ解除 - currentTheme = deepClone(theme); + if (theme.id === currentThemeId) return; + currentThemeId = theme.id; if (window.document.startViewTransition != null) { window.document.documentElement.classList.add('_themeChanging_'); |