From 15ab198af0d2859d93f4863b98794a2b4f6f1da2 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 28 Jan 2024 09:39:58 +0100 Subject: [PATCH] Enable night mode on /login if that's the system preferred color scheme (references #71) --- changelog/74_UNRELEASED_xxxx-xx-xx.md | 1 + public/js/grocy_nightmode.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog/74_UNRELEASED_xxxx-xx-xx.md b/changelog/74_UNRELEASED_xxxx-xx-xx.md index d8e15835..aa4f3704 100644 --- a/changelog/74_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/74_UNRELEASED_xxxx-xx-xx.md @@ -57,6 +57,7 @@ ### General +- Night mode is now also used on the login page if that's the system preferred color scheme (generally if night mode is on or not is based on user settings and before logging in no user context is available) - Optimized sidebar icon spacing (thanks @chris-thorn) - Fixed that file uploads (product pictures and so on) didn't work for files where the file name contains multiple spaces - Fixed that some dialogs were not properly (too small) displayed in Firefox >= 121 diff --git a/public/js/grocy_nightmode.js b/public/js/grocy_nightmode.js index dd9fd6e2..c785668c 100644 --- a/public/js/grocy_nightmode.js +++ b/public/js/grocy_nightmode.js @@ -49,9 +49,9 @@ $("#auto-night-mode-time-range-goes-over-midgnight").on("change", function() function CheckNightMode() { - if (Grocy.UserId === -1) + if (Grocy.UserId === -1) // Not logged in => always use system preferred color scheme { - return; + Grocy.UserSettings.night_mode = "follow-system"; } var nightModeEnabledInternalBefore = Grocy.UserSettings.night_mode_enabled_internal; @@ -132,8 +132,6 @@ if (Grocy.UserId !== -1) $("#auto-night-mode-time-range-from").trigger("keyup"); $("#auto-night-mode-time-range-to").val(Grocy.UserSettings.auto_night_mode_time_range_to); $("#auto-night-mode-time-range-to").trigger("keyup"); - - CheckNightMode(); } if (Grocy.Mode === "production") @@ -144,3 +142,5 @@ else { setInterval(CheckNightMode, 4000); } + +CheckNightMode();