From cf52c4c0a8453f0e1999508b32006f6e49606beb Mon Sep 17 00:00:00 2001 From: Pexle Chris Date: Sun, 27 Apr 2025 15:13:21 +0300 Subject: [PATCH] AdminerDarkSwitcher: Handle first click Fixed an issue where the Dark Mode Switcher icon did not respond on the first click if the Dark Mode cookie had not been set yet. Now, clicking the icon correctly sets the cookie and immediately toggles Dark Mode. --- plugins/dark-switcher.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/dark-switcher.php b/plugins/dark-switcher.php index df3ef2ac..10ea97f5 100644 --- a/plugins/dark-switcher.php +++ b/plugins/dark-switcher.php @@ -28,6 +28,8 @@ const saved = document.cookie.match(/adminer_dark=(\d)/); if (saved) { adminerDark = +saved[1]; adminerDarkSet(); +} else { + adminerDark = +matchMedia('(prefers-color-scheme: dark)').matches; } ☀" - . Adminer\script("if (adminerDark != null) adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n" + . Adminer\script("adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n" ; }