diff --git a/client/src/store/authStore.ts b/client/src/store/authStore.ts index 8d8c342d..6237cd6d 100644 --- a/client/src/store/authStore.ts +++ b/client/src/store/authStore.ts @@ -4,7 +4,6 @@ import { authApi } from '../api/client' import { connect, disconnect } from '../api/websocket' import type { User } from '../types' import { getApiErrorMessage } from '../types' -import { tripSyncManager } from '../sync/tripSyncManager' import { clearAll } from '../db/offlineDb' import { useSystemNoticeStore } from './systemNoticeStore.js' @@ -100,7 +99,6 @@ export const useAuthStore = create()( error: null, }) connect() - tripSyncManager.syncAll().catch(console.error) if (!data.user?.must_change_password) { useSystemNoticeStore.getState().fetch() } @@ -124,7 +122,6 @@ export const useAuthStore = create()( error: null, }) connect() - tripSyncManager.syncAll().catch(console.error) if (!data.user?.must_change_password) { useSystemNoticeStore.getState().fetch() } @@ -148,7 +145,6 @@ export const useAuthStore = create()( error: null, }) connect() - tripSyncManager.syncAll().catch(console.error) useSystemNoticeStore.getState().fetch() return data } catch (err: unknown) { diff --git a/client/src/sync/syncTriggers.ts b/client/src/sync/syncTriggers.ts index 2c84afe1..7680fcfc 100644 --- a/client/src/sync/syncTriggers.ts +++ b/client/src/sync/syncTriggers.ts @@ -1,19 +1,19 @@ /** * Sync triggers — register event listeners that flush the mutation queue - * and/or run a full trip sync based on the connectivity trigger source. + * based on the connectivity trigger source. * * Trigger matrix: - * window 'online' → flush mutations + full syncAll (network truly back) + * window 'online' → flush mutations (network truly back) * visibilitychange visible → flush mutations only (avoid hammering server on tab switch) * periodic 30s → flush mutations only - * WS reconnect → flush mutations only (no syncAll — avoids rate-limiter - * on server restart / socket timeout while already online) + * WS reconnect → flush mutations only + * + * Full trip sync (syncAll) is manual-only via the Offline settings tab. * * Call `registerSyncTriggers()` once on app mount. * Call `unregisterSyncTriggers()` on unmount / logout. */ import { mutationQueue } from './mutationQueue' -import { tripSyncManager } from './tripSyncManager' import { setPreReconnectHook } from '../api/websocket' const PERIODIC_MS = 30_000 @@ -21,10 +21,9 @@ const PERIODIC_MS = 30_000 let _intervalId: ReturnType | null = null let _registered = false -/** Network came back — flush mutations AND re-seed Dexie for all cacheable trips. */ +/** Network came back — flush any pending mutations. */ function onOnline() { mutationQueue.flush().catch(console.error) - tripSyncManager.syncAll().catch(console.error) } /** Tab became visible — flush only; don't trigger a potentially expensive syncAll. */