fix(sync): read the open trip's addons again after the socket reconnects

A tripAddons:changed push is not replayed, so a switch made while the socket was
down now reaches the member on the reconnect refetch.
This commit is contained in:
Maurice
2026-11-23 14:55:53 +01:00
parent 769293a554
commit c3d60e1c43
2 changed files with 15 additions and 2 deletions
+4 -1
View File
@@ -18,6 +18,7 @@ import { isEffectivelyOnline, onNetworkModeChange } from './networkMode'
import { setPreReconnectHook, setRefetchCallback, getActiveTrips, reconnectNow } from '../api/websocket'
import { useTripStore } from '../store/tripStore'
import { reloadTourVisits } from '../store/tourVisitStore'
import { useTripAddonsStore } from '../store/tripAddonsStore'
import { useSettingsStore } from '../store/settingsStore'
import { useAuthStore } from '../store/authStore'
@@ -113,10 +114,12 @@ export function registerSyncTriggers(): void {
setPreReconnectHook(() => mutationQueue.flush())
// After the reconnect flush, pull canonical state for the open trip back into
// the store (the WS layer awaits the flush hook before invoking this), and
// the walk visits, so a mark the replay dropped or failed leaves the day plan.
// the walk visits, so a mark the replay dropped or failed leaves the day plan,
// and the trip's addons, whose change pushed while the socket was down is lost.
setRefetchCallback(tripId => {
useTripStore.getState().hydrateActiveTrip(tripId).catch(console.error)
reloadTourVisits(tripId)
void useTripAddonsStore.getState().load(Number(tripId))
})
window.addEventListener('online', onOnline)