NOW MANAGED ON CODEBERG
Dark Mode: Fixed not toggle action when dark by default
Dan Brown417705651c66
diff --git a/app/Users/Controllers/UserPreferencesController.php b/app/Users/Controllers/UserPreferencesController.phpindex 9c38ff2af..08d65743b 100644--- a/app/Users/Controllers/UserPreferencesController.php+++ b/app/Users/Controllers/UserPreferencesController.php@@ -145,7 +145,7 @@ class UserPreferencesController extends Controller*/public function toggleDarkMode(){- $enabled = setting()->getForCurrentUser('dark-mode-enabled', false);+ $enabled = setting()->getForCurrentUser('dark-mode-enabled');setting()->putForCurrentUser('dark-mode-enabled', $enabled ? 'false' : 'true');return redirect()->back();diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.phpindex 1b16b0b45..f5dae3e76 100644--- a/tests/User/UserPreferencesTest.php+++ b/tests/User/UserPreferencesTest.php@@ -242,6 +242,22 @@ class UserPreferencesTest extends TestCase$this->withHtml($home)->assertElementExists('.dark-mode');}+ public function test_dark_mode_toggle_endpoint_changes_to_light_when_dark_by_default()+ {+ config()->set('setting-defaults.user.dark-mode-enabled', true);+ $editor = $this->users->editor();++ $this->assertEquals(true, setting()->getUser($editor, 'dark-mode-enabled'));+ $prefChange = $this->actingAs($editor)->patch('/preferences/toggle-dark-mode');+ $prefChange->assertRedirect();+ $this->assertEquals(false, setting()->getUser($editor, 'dark-mode-enabled'));++ $home = $this->get('/');+ $this->withHtml($home)->assertElementNotExists('.dark-mode');+ $home->assertDontSee('Light Mode');+ $home->assertSee('Dark Mode');+ }+public function test_books_view_type_preferences_when_list(){$editor = $this->users->editor();