mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
settings: Add automatic theme detection feature.
With this implementation of the feature of the automatic theme detection, we make the following changes in the backend, frontend and documentation. This replaces the previous night_mode boolean with an enum, with the default value being to use the prefers-color-scheme feature of the operating system to determine which theme to use. Fixes: #14451. Co-authored-by: @kPerikou <44238834+kPerikou@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,7 @@ from zerver.models import UserProfile
|
||||
|
||||
def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]:
|
||||
def change_mode_setting(command: str, switch_command: str,
|
||||
setting: str, setting_value: bool) -> str:
|
||||
setting: str, setting_value: int) -> str:
|
||||
msg = 'Changed to {command} mode! To revert ' \
|
||||
'{command} mode, type `/{switch_command}`.'.format(
|
||||
command=command,
|
||||
@@ -27,19 +27,19 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
|
||||
if command == 'ping':
|
||||
return dict()
|
||||
elif command == 'night':
|
||||
if user_profile.night_mode:
|
||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_NIGHT:
|
||||
return dict(msg='You are still in night mode.')
|
||||
return dict(msg=change_mode_setting(command=command,
|
||||
switch_command='day',
|
||||
setting='night_mode',
|
||||
setting_value=True))
|
||||
setting='color_scheme',
|
||||
setting_value=UserProfile.COLOR_SCHEME_NIGHT))
|
||||
elif command == 'day':
|
||||
if not user_profile.night_mode:
|
||||
if user_profile.color_scheme == UserProfile.COLOR_SCHEME_LIGHT:
|
||||
return dict(msg='You are still in day mode.')
|
||||
return dict(msg=change_mode_setting(command=command,
|
||||
switch_command='night',
|
||||
setting='night_mode',
|
||||
setting_value=False))
|
||||
setting='color_scheme',
|
||||
setting_value=UserProfile.COLOR_SCHEME_LIGHT))
|
||||
elif command == 'fluid-width':
|
||||
if user_profile.fluid_layout_width:
|
||||
return dict(msg='You are still in fluid width mode.')
|
||||
|
||||
Reference in New Issue
Block a user