mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
fix: keep localStorage cache in sync with server settings
When switching between Electron and web modes or when the server temporarily stops, web mode was falling back to stale localStorage data instead of fresh server data. This fix: 1. Updates localStorage cache whenever fresh server settings are fetched 2. Updates localStorage cache whenever settings are synced to server 3. Prioritizes fresh settings cache over old Zustand persisted storage This ensures that: - Web mode always sees the latest projects even after mode switches - Switching from Electron to web mode immediately shows new projects - Server restarts don't cause web mode to use stale cached data Fixes issue where projects opened in Electron didn't appear in web mode after stopping and restarting the server. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -215,6 +215,15 @@ export function useSettingsSync(): SettingsSyncState {
|
||||
if (result.success) {
|
||||
lastSyncedRef.current = updateHash;
|
||||
logger.debug('Settings synced to server');
|
||||
|
||||
// Update localStorage cache with synced settings to keep it fresh
|
||||
// This prevents stale data when switching between Electron and web modes
|
||||
try {
|
||||
setItem('automaker-settings-cache', JSON.stringify(updates));
|
||||
logger.debug('Updated localStorage cache after sync');
|
||||
} catch (storageError) {
|
||||
logger.warn('Failed to update localStorage cache after sync:', storageError);
|
||||
}
|
||||
} else {
|
||||
logger.error('Failed to sync settings:', result.error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user