mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
settings: Extract code for checking night-mode setting.
We extract the code for checking night mode setting on the basis of color_scheme value and using matchMedia when color_scheme is set to automatic. This is currently used in rendering the correct logo only. This is a prep commit for fixing loading indicator not visible on message-edit button in night-mode.
This commit is contained in:
@@ -158,3 +158,18 @@ export function user_can_edit_topic_of_any_message() {
|
||||
}
|
||||
return user_has_permission(page_params.realm_edit_topic_policy);
|
||||
}
|
||||
|
||||
export function using_dark_theme() {
|
||||
if (page_params.color_scheme === settings_config.color_scheme_values.night.code) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
page_params.color_scheme === settings_config.color_scheme_values.automatic.code &&
|
||||
window.matchMedia &&
|
||||
window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user