forked from mystiq/hydrogen-web
Merge pull request #751 from vector-im/fix-theming-watch
Fix: don't crash on platforms that don't have a preferred color scheme
This commit is contained in:
commit
e643ffb334
2 changed files with 1 additions and 6 deletions
|
@ -187,9 +187,5 @@ export class SettingsViewModel extends ViewModel {
|
||||||
// emit so that radio-buttons become displayed/hidden
|
// emit so that radio-buttons become displayed/hidden
|
||||||
this.emitChange("themeOption");
|
this.emitChange("themeOption");
|
||||||
}
|
}
|
||||||
|
|
||||||
get preferredColorScheme() {
|
|
||||||
return this.platform.themeLoader.preferredColorScheme;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,13 +196,12 @@ export class ThemeLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get preferredColorScheme(): ColorSchemePreference {
|
get preferredColorScheme(): ColorSchemePreference | undefined {
|
||||||
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||||
return ColorSchemePreference.Dark;
|
return ColorSchemePreference.Dark;
|
||||||
}
|
}
|
||||||
else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
||||||
return ColorSchemePreference.Light;
|
return ColorSchemePreference.Light;
|
||||||
}
|
}
|
||||||
throw new Error("Cannot find preferred colorscheme!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue