The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(sync): read the open trip's addons again after the socket reconnects
Mauricec3d60e1c4399
diff --git a/client/src/sync/syncTriggers.ts b/client/src/sync/syncTriggers.tsindex 505503f65..6f2a6a082 100644--- a/client/src/sync/syncTriggers.ts+++ b/client/src/sync/syncTriggers.ts@@ -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)diff --git a/client/tests/unit/sync/syncTriggers.test.ts b/client/tests/unit/sync/syncTriggers.test.tsindex 10db13d0e..7ca4d549d 100644--- a/client/tests/unit/sync/syncTriggers.test.ts+++ b/client/tests/unit/sync/syncTriggers.test.ts@@ -11,6 +11,7 @@ const syncAll = vi.fn(() => Promise.resolve());const hydrate = vi.fn(() => Promise.resolve());const loadSettings = vi.fn(() => Promise.resolve());const reloadVisits = vi.fn();+const loadTripAddons = vi.fn(() => Promise.resolve());let refetchCb: ((tripId: string) => void) | null = null;let preReconnect: (() => Promise<void>) | null = null;@@ -36,6 +37,9 @@ vi.mock('../../../src/store/tripStore', () => ({vi.mock('../../../src/store/tourVisitStore', () => ({reloadTourVisits: (tripId: string) => reloadVisits(tripId),}));+vi.mock('../../../src/store/tripAddonsStore', () => ({+ useTripAddonsStore: { getState: () => ({ load: loadTripAddons }) },+}));vi.mock('../../../src/store/settingsStore', () => ({useSettingsStore: { getState: () => ({ isLoaded: settingsLoaded, loadSettings }) },}));@@ -50,7 +54,7 @@ const flushMicrotasks = async () => {};beforeEach(() => {- flush.mockClear(); syncAll.mockClear(); hydrate.mockClear(); loadSettings.mockClear(); reloadVisits.mockClear();+ flush.mockClear(); syncAll.mockClear(); hydrate.mockClear(); loadSettings.mockClear(); reloadVisits.mockClear(); loadTripAddons.mockClear();refetchCb = null; preReconnect = null; reconnects = 0;settingsLoaded = false; authenticated = true;Object.defineProperty(navigator, 'onLine', { value: true, writable: true, configurable: true });@@ -74,6 +78,12 @@ describe('syncTriggers', () => {expect(reloadVisits).toHaveBeenCalledWith('7');});+ it('the refetch after a reconnect reads the trip addons again, a switch pushed while the socket was down included', () => {+ registerSyncTriggers();+ refetchCb?.('7');+ expect(loadTripAddons).toHaveBeenCalledWith(7);+ });+it('also registers the pre-reconnect flush hook', () => {registerSyncTriggers();expect(preReconnect).toBeTypeOf('function');