From 02ac421010d80bb55b2074777e282068f49675e5 Mon Sep 17 00:00:00 2001 From: Nestoras Sdoukos Date: Thu, 21 Mar 2024 22:31:37 +0200 Subject: [PATCH] Fix night mode when changing theme Signed-off-by: Nestoras Sdoukos --- app/js/custom.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index 9dfc98f7..f6e24558 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -753,8 +753,21 @@ $(document).on("click", ".js-toggle-password", function(e) { $(function() { $('#theme-select').change(function() { - var theme = themes[$( "#theme-select" ).val() ]; - set_theme(theme); + var theme = themes[$( "#theme-select" ).val() ]; + + var hasDarkTheme = theme === 'custom.php' || + theme === 'material-light.php'; + var nightModeChecked = $("#night-mode").prop("checked"); + + if (nightModeChecked && hasDarkTheme) { + if (theme === "custom.php") { + set_theme("lightsout.php"); + } else if (theme === "material-light.php") { + set_theme("material-dark.php"); + } + } else { + set_theme(theme); + } }); });