mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
feat: enhance global settings update with data loss prevention
- Added safeguards to prevent overwriting non-empty arrays with empty arrays during global settings updates, specifically for the 'projects' field. - Implemented logging for updates to assist in diagnosing accidental wipes of critical settings. - Updated tests to verify that projects are preserved during logout transitions and that theme changes are ignored if a project wipe is attempted. - Enhanced the settings synchronization logic to ensure safe handling during authentication state changes.
This commit is contained in:
@@ -81,9 +81,23 @@ export const THEME_STORAGE_KEY = 'automaker:theme';
|
||||
*/
|
||||
export function getStoredTheme(): ThemeMode | null {
|
||||
const stored = getItem(THEME_STORAGE_KEY);
|
||||
if (stored) {
|
||||
return stored as ThemeMode;
|
||||
if (stored) return stored as ThemeMode;
|
||||
|
||||
// Backwards compatibility: older versions stored theme inside the Zustand persist blob.
|
||||
// We intentionally keep reading it as a fallback so users don't get a "default theme flash"
|
||||
// on login/logged-out pages if THEME_STORAGE_KEY hasn't been written yet.
|
||||
try {
|
||||
const legacy = getItem('automaker-storage');
|
||||
if (!legacy) return null;
|
||||
const parsed = JSON.parse(legacy) as { state?: { theme?: unknown } } | { theme?: unknown };
|
||||
const theme = (parsed as any)?.state?.theme ?? (parsed as any)?.theme;
|
||||
if (typeof theme === 'string' && theme.length > 0) {
|
||||
return theme as ThemeMode;
|
||||
}
|
||||
} catch {
|
||||
// Ignore legacy parse errors
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user