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:
webdevcody
2026-01-07 21:38:46 -05:00
parent 8c68c24716
commit d8cdb0bf7a
7 changed files with 190 additions and 13 deletions

View File

@@ -94,6 +94,17 @@ export function waitForMigrationComplete(): Promise<void> {
return migrationCompletePromise;
}
/**
* Reset migration state when auth is lost (logout/session expired).
* This ensures that on re-login, the sync hook properly waits for
* fresh settings hydration before starting to sync.
*/
export function resetMigrationState(): void {
migrationCompleted = false;
migrationCompletePromise = null;
migrationCompleteResolve = null;
}
/**
* Parse localStorage data into settings object
*/