dark_theme: Add automatic color scheme support for spectators.

Similar to the light/dark theme support for the spectators, this adds
the automatic color scheme support by storing the user's preference
in the local storage.
This commit is contained in:
Sayam Samal
2024-06-06 00:50:05 +05:30
committed by Tim Abbott
parent e41d1fb48f
commit 2f6cc4a6b0
2 changed files with 8 additions and 0 deletions

View File

@@ -27,4 +27,10 @@ export function disable(): void {
export function default_preference_checker(): void { export function default_preference_checker(): void {
$(":root").removeClass("dark-theme").addClass("color-scheme-automatic"); $(":root").removeClass("dark-theme").addClass("color-scheme-automatic");
if (page_params.is_spectator) {
const ls = localstorage();
ls.set("spectator-theme-preference", "automatic");
user_settings.color_scheme = settings_config.color_scheme_values.automatic.code;
}
} }

View File

@@ -429,6 +429,8 @@ export function initialize_everything(state_data) {
dark_theme.enable(); dark_theme.enable();
} else if (preferred_theme === "light") { } else if (preferred_theme === "light") {
dark_theme.disable(); dark_theme.disable();
} else {
dark_theme.default_preference_checker();
} }
} }