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:
Bruno Windels 2022-06-14 16:00:13 +02:00 committed by GitHub
commit e643ffb334
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 6 deletions

View file

@ -187,9 +187,5 @@ export class SettingsViewModel extends ViewModel {
// emit so that radio-buttons become displayed/hidden
this.emitChange("themeOption");
}
get preferredColorScheme() {
return this.platform.themeLoader.preferredColorScheme;
}
}

View file

@ -196,13 +196,12 @@ export class ThemeLoader {
}
}
get preferredColorScheme(): ColorSchemePreference {
get preferredColorScheme(): ColorSchemePreference | undefined {
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return ColorSchemePreference.Dark;
}
else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
return ColorSchemePreference.Light;
}
throw new Error("Cannot find preferred colorscheme!");
}
}