This commit is contained in:
grimsi
2025-07-18 10:49:34 +02:00
parent 749b031db1
commit f401bd8c78
7 changed files with 39 additions and 25 deletions
@@ -5,13 +5,14 @@ import {themes} from "Frontend/theming/themes";
import {Theme} from "Frontend/theming/theme";
import ThemePreview from "Frontend/components/theming/ThemePreview";
import {toTitleCase} from "Frontend/util/utils";
import {UserPreferenceService} from "Frontend/util/user-preference-service";
import {useUserPreferenceService} from "Frontend/util/user-preference-service";
export function ThemeSelector() {
const {theme, setTheme} = useTheme();
const [selectedTheme, setSelectedTheme] = useState(theme?.substring(0, theme?.lastIndexOf("-")));
const [selectedMode, setSelectedMode] = useState<Selection>();
const userPreferenceService = useUserPreferenceService();
useEffect(() => {
if (!selectedMode)
@@ -24,7 +25,7 @@ export function ThemeSelector() {
if (selectedMode instanceof Set) {
let theme = `${selectedTheme}-${selectedMode.values().next().value}`;
setTheme(theme);
UserPreferenceService.set("preferred-theme", theme).catch(console.error);
userPreferenceService.set("preferred-theme", theme).catch(console.error);
}
}