mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
fix: sync projects immediately instead of debouncing
Projects are critical data that must persist across mode switches (Electron/web). Previously, project changes were debounced by 1 second, which could cause data loss if: 1. User switched from Electron to web mode quickly 2. App closed before debounce timer fired 3. Network temporarily unavailable during debounce window This change makes project array changes sync immediately (syncNow) instead of using the 1-second debounce, ensuring projects are always persisted to the server right away and visible in both Electron and web modes. Fixes issue where projects opened in Electron didn't appear in web mode. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -340,9 +340,22 @@ export function useSettingsSync(): SettingsSyncState {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if any synced field changed
|
||||
// If projects array changed (by reference, meaning content changed), sync immediately
|
||||
// This is critical - projects list changes must sync right away to prevent loss
|
||||
// when switching between Electron and web modes or closing the app
|
||||
if (newState.projects !== prevState.projects) {
|
||||
logger.debug('Projects array changed, syncing immediately', {
|
||||
prevCount: prevState.projects?.length ?? 0,
|
||||
newCount: newState.projects?.length ?? 0,
|
||||
});
|
||||
syncNow();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if any other synced field changed
|
||||
let changed = false;
|
||||
for (const field of SETTINGS_FIELDS_TO_SYNC) {
|
||||
if (field === 'projects') continue; // Already handled above
|
||||
if (hasSettingsFieldChanged(field, newState, prevState)) {
|
||||
changed = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user