fix(frontend): visibilityStateがhiddenな状態でstartViewTransitionしないように

This commit is contained in:
syuilo
2025-12-01 08:21:30 +09:00
committed by GitHub
parent 128fe6d644
commit e1b6e9d4b6

View File

@@ -144,7 +144,9 @@ export function applyTheme(theme: Theme, persist = true) {
if (theme.id === currentThemeId && miLocalStorage.getItem('themeCachedVersion') === version) return;
currentThemeId = theme.id;
if (window.document.startViewTransition != null) {
// visibilityStateがhiddenな状態でstartViewTransitionするとブラウザによってはエラーになる
// 通常hiddenな時に呼ばれることはないが、iOSのPWAだとアプリ切り替え時に(何故か)hiddenな状態で(何故か)一瞬デバイスのダークモード判定が変わりapplyThemeが呼ばれる場合がある
if (window.document.startViewTransition != null && window.document.visibilityState === 'visible') {
window.document.documentElement.classList.add('_themeChanging_');
try {
window.document.startViewTransition(async () => {