Skip to content

Commit 07d2e04

Browse files
committed
Automatically detect and apply OS theme in Login screen
https://community.openproject.org/work_packages/66594
1 parent 8a49763 commit 07d2e04

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/helpers/application_helper.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,17 @@ def body_data_attributes(local_assigns)
317317
end
318318

319319
def user_theme_data_attributes
320-
if User.current.pref.sync_with_os_theme?
321-
# Theme will be set by inline script before body renders to prevent flickering
322-
{ auto_theme_switcher_mode_value: User.current.pref.theme,
320+
current_user = User.current
321+
322+
if current_user.anonymous? || current_user.pref.sync_with_os_theme?
323+
{ auto_theme_switcher_mode_value: :sync_with_os,
323324
auto_theme_switcher_desktop_light_high_contrast_logo_class: "op-logo--link_high_contrast",
324325
auto_theme_switcher_mobile_white_logo_class: "op-logo--icon_white" }
325326
else
326-
mode, _theme_suffix = User.current.pref.theme.split("_", 2)
327+
mode, _theme_suffix = current_user.pref.theme.split("_", 2)
327328
{
328329
color_mode: mode,
329-
"#{mode}_theme": User.current.pref.theme
330+
"#{mode}_theme": current_user.pref.theme
330331
}
331332
end
332333
end

0 commit comments

Comments
 (0)