From b3fa316bf990bdf4a17da7379a163092791ffb23 Mon Sep 17 00:00:00 2001 From: Daniel Heidemann Date: Wed, 6 Mar 2024 15:22:26 +0100 Subject: [PATCH] fixed theme cookie setter --- frontend/lib/utils/cookie.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/lib/utils/cookie.dart b/frontend/lib/utils/cookie.dart index 573927a..2c176c1 100644 --- a/frontend/lib/utils/cookie.dart +++ b/frontend/lib/utils/cookie.dart @@ -62,9 +62,11 @@ void setTokenCookieFromUrl() { } void setThemeCookie([String? theme]) { - theme ??= ThemeMode.system == ThemeMode.dark ? "dark" : "light"; + if (theme == null && getValueOfCookie("theme") == null) { + theme = ThemeMode.system == ThemeMode.dark ? "dark" : "light"; + } int exp = DateTime.now().add(const Duration(days: 365)).millisecondsSinceEpoch ~/ 1000000; - setCookie("theme", theme, exp); + if (theme != null) setCookie("theme", theme, exp); }