From 1317cd6bc27b4988b49f208bb4bbcb11c7a8e947 Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 28 Jul 2025 12:09:51 +0200 Subject: [PATCH 1/3] Fix dark theme --- frontend/src/models/Settings.model.ts | 5 ++++- frontend/src/services/System/SystemWebClient/index.ts | 6 ++++++ frontend/src/services/System/index.ts | 1 + frontend/templates/frontend/index.ejs | 10 +++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/models/Settings.model.ts b/frontend/src/models/Settings.model.ts index 4980b8a5..5bb6e87b 100644 --- a/frontend/src/models/Settings.model.ts +++ b/frontend/src/models/Settings.model.ts @@ -67,7 +67,10 @@ class BaseSettings { } getMode = (): 'light' | 'dark' => { - return window?.matchMedia('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light'; + return (systemClient.getSyncItem?.('settings_mode') as 'light' | 'dark') || + window?.matchMedia('(prefers-color-scheme: dark)')?.matches + ? 'dark' + : 'light'; }; public frontend: 'basic' | 'pro' = 'basic'; diff --git a/frontend/src/services/System/SystemWebClient/index.ts b/frontend/src/services/System/SystemWebClient/index.ts index 5a9f3ce2..379e49b9 100644 --- a/frontend/src/services/System/SystemWebClient/index.ts +++ b/frontend/src/services/System/SystemWebClient/index.ts @@ -33,6 +33,12 @@ class SystemWebClient implements SystemClient { return value ?? ''; }; + // Local storage + public getSyncItem: (key: string) => string | undefined = (key) => { + const value = window.localStorage.getItem(key); + return value ?? ''; + }; + public setItem: (key: string, value: string) => void = (key, value) => { window.localStorage.setItem(key, value); }; diff --git a/frontend/src/services/System/index.ts b/frontend/src/services/System/index.ts index 62e6454e..63ed7dba 100644 --- a/frontend/src/services/System/index.ts +++ b/frontend/src/services/System/index.ts @@ -5,6 +5,7 @@ import SystemAndroidClient from './SystemAndroidClient'; export interface SystemClient { loading: boolean; copyToClipboard: (value: string) => void; + getSyncItem?: (key: string) => string | undefined; getItem: (key: string) => Promise; setItem: (key: string, value: string) => void; deleteItem: (key: string) => void; diff --git a/frontend/templates/frontend/index.ejs b/frontend/templates/frontend/index.ejs index 5fca6f57..41a853d8 100644 --- a/frontend/templates/frontend/index.ejs +++ b/frontend/templates/frontend/index.ejs @@ -63,6 +63,14 @@ color: #c0392b; text-decoration: underline; } + + /* Dark mode styles based on system preference */ + @media (prefers-color-scheme: dark) { + body { + background-color: black; + color: #f0f0f0; + } + } @@ -116,4 +124,4 @@ - \ No newline at end of file + From 3d8d971028ac0e6679a41f74ac5f861f871907e0 Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 28 Jul 2025 12:10:44 +0200 Subject: [PATCH 2/3] Remove code --- frontend/src/services/System/SystemWebClient/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/services/System/SystemWebClient/index.ts b/frontend/src/services/System/SystemWebClient/index.ts index 379e49b9..d671e8d3 100644 --- a/frontend/src/services/System/SystemWebClient/index.ts +++ b/frontend/src/services/System/SystemWebClient/index.ts @@ -33,7 +33,6 @@ class SystemWebClient implements SystemClient { return value ?? ''; }; - // Local storage public getSyncItem: (key: string) => string | undefined = (key) => { const value = window.localStorage.getItem(key); return value ?? ''; From 7f5e0b3796ab4a426dd82f77b873e45ec3b27db3 Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 28 Jul 2025 12:11:01 +0200 Subject: [PATCH 3/3] Remove code --- frontend/templates/frontend/index.ejs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/frontend/templates/frontend/index.ejs b/frontend/templates/frontend/index.ejs index 41a853d8..5fca6f57 100644 --- a/frontend/templates/frontend/index.ejs +++ b/frontend/templates/frontend/index.ejs @@ -63,14 +63,6 @@ color: #c0392b; text-decoration: underline; } - - /* Dark mode styles based on system preference */ - @media (prefers-color-scheme: dark) { - body { - background-color: black; - color: #f0f0f0; - } - } @@ -124,4 +116,4 @@ - + \ No newline at end of file