mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +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:
35
zerver/migrations/0290_remove_night_mode_add_color_scheme.py
Normal file
35
zerver/migrations/0290_remove_night_mode_add_color_scheme.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 2.2.13 on 2020-06-20 15:22
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
COLOR_SCHEME_AUTOMATIC = 1
|
||||
COLOR_SCHEME_NIGHT = 2
|
||||
|
||||
# Set color_scheme to night mode, if night_mode is True.
|
||||
def set_color_scheme_to_night_mode(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||
UserProfile = apps.get_model("zerver", "UserProfile")
|
||||
UserProfile.objects.filter(night_mode=True).update(color_scheme=COLOR_SCHEME_NIGHT)
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('zerver', '0289_tighten_attachment_size'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='userprofile',
|
||||
name='color_scheme',
|
||||
field=models.PositiveSmallIntegerField(default=COLOR_SCHEME_AUTOMATIC),
|
||||
),
|
||||
migrations.RunPython(
|
||||
set_color_scheme_to_night_mode,
|
||||
reverse_code=migrations.RunPython.noop,
|
||||
elidable=True),
|
||||
migrations.RemoveField(
|
||||
model_name='userprofile',
|
||||
name='night_mode',
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user