Sync theme changes to encrypted settings

- Update useTheme to save theme to encrypted storage when changed
- Theme now syncs across devices like other settings
- Prompts signer when changing theme while logged in

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy
2026-02-18 03:31:51 -06:00
parent f46e7facf1
commit c0f6bd6bbb
+11 -1
View File
@@ -1,5 +1,7 @@
import { type Theme } from "@/contexts/AppContext";
import { useAppContext } from "@/hooks/useAppContext";
import { useEncryptedSettings } from "@/hooks/useEncryptedSettings";
import { useCurrentUser } from "@/hooks/useCurrentUser";
/**
* Hook to get and set the active theme
@@ -7,14 +9,22 @@ import { useAppContext } from "@/hooks/useAppContext";
*/
export function useTheme(): { theme: Theme; setTheme: (theme: Theme) => void } {
const { config, updateConfig } = useAppContext();
const { updateSettings } = useEncryptedSettings();
const { user } = useCurrentUser();
return {
theme: config.theme,
setTheme: (theme: Theme) => {
setTheme: async (theme: Theme) => {
// Update local immediately
updateConfig((currentConfig) => ({
...currentConfig,
theme,
}));
// Sync to encrypted storage if logged in
if (user) {
await updateSettings.mutateAsync({ theme });
}
}
}
}