dark_theme: Fix dark recipient background in light theme for spectators.

Since, we didn't update `user_settings.color_scheme` for spectators
and our recipient bar color calculations were based on it, this
resulted in a wrong recipient bar color if the OS default color
scheme of the user was different from `spectator-theme-preference`
set by the user using the gear menu.

To reproduce the bug:
* Set preferred color scheme to `dark` in your OS settings / Chrome
  dev tools.
* Login as spectator in Incognito.
* Switch to light theme.

You will see dark background colors in recipient bars.
This commit is contained in:
Aman Agrawal
2023-04-28 17:51:11 +00:00
committed by Tim Abbott
parent f574bd4952
commit 2deec692f6
2 changed files with 7 additions and 1 deletions

View File

@@ -573,6 +573,9 @@ export function initialize_everything() {
const user_settings_params = pop_fields("user_settings");
const realm_settings_defaults_params = pop_fields("realm_user_settings_defaults");
/* To store theme data for spectators, we need to initialize
user_settings before setting the theme. */
initialize_user_settings(user_settings_params);
if (page_params.is_spectator) {
const ls = localstorage();
const preferred_theme = ls.get("spectator-theme-preference");
@@ -588,7 +591,6 @@ export function initialize_everything() {
popovers.initialize();
popover_menus.initialize();
initialize_user_settings(user_settings_params);
realm_user_settings_defaults.initialize(realm_settings_defaults_params);
people.initialize(page_params.user_id, people_params);