mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 09:58:06 +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:
@@ -791,17 +791,7 @@ export function dispatch_normal_event(event) {
|
||||
}
|
||||
if (event.property === "color_scheme") {
|
||||
requestAnimationFrame(() => {
|
||||
if (event.value === settings_config.color_scheme_values.night.code) {
|
||||
dark_theme.enable();
|
||||
realm_logo.render();
|
||||
} else if (event.value === settings_config.color_scheme_values.day.code) {
|
||||
dark_theme.disable();
|
||||
realm_logo.render();
|
||||
} else {
|
||||
dark_theme.default_preference_checker();
|
||||
realm_logo.render();
|
||||
}
|
||||
message_lists.update_recipient_bar_background_color();
|
||||
dark_theme.set_theme_and_update(event.value);
|
||||
});
|
||||
}
|
||||
if (event.property === "starred_message_counts") {
|
||||
|
||||
Reference in New Issue
Block a user