mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
dark_theme: Refactor and consolidate theme setting logic.
This commit centralizes the logic for setting a user's theme preference, both for regular users and spectators, into the `dark_theme.ts` module. This simplifies theme handling throughout the codebase and ensures that the theme is set consistently across all modules. Instead of relying on various call sites to update the recipient bar's background color and switch between the light/dark realm logo after a theme change, this commit modifies the `set_theme_and_update` function to include these calls after every theme change. Before this commit, some modules used to update the realm logo after a theme change, while others did not. This led to inconsistencies in the UI depending on which method was used to change the theme.
This commit is contained in:
@@ -58,7 +58,6 @@ import * as left_sidebar_navigation_area_popovers from "./left_sidebar_navigatio
|
||||
import * as lightbox from "./lightbox";
|
||||
import * as linkifiers from "./linkifiers";
|
||||
import * as local_message from "./local_message";
|
||||
import {localstorage} from "./localstorage";
|
||||
import * as markdown from "./markdown";
|
||||
import * as markdown_config from "./markdown_config";
|
||||
import * as message_actions_popover from "./message_actions_popover";
|
||||
@@ -423,15 +422,7 @@ export function initialize_everything(state_data) {
|
||||
sidebar_ui.restore_sidebar_toggle_status();
|
||||
information_density.initialize();
|
||||
if (page_params.is_spectator) {
|
||||
const ls = localstorage();
|
||||
const preferred_theme = ls.get("spectator-theme-preference");
|
||||
if (preferred_theme === "dark") {
|
||||
dark_theme.enable();
|
||||
} else if (preferred_theme === "light") {
|
||||
dark_theme.disable();
|
||||
} else {
|
||||
dark_theme.default_preference_checker();
|
||||
}
|
||||
dark_theme.initialize_theme_for_spectator();
|
||||
}
|
||||
|
||||
i18n.initialize({language_list: page_params.language_list});
|
||||
|
||||
Reference in New Issue
Block a user