fix(offline): cache accommodations, trip members, tags, and categories for full offline support

This commit is contained in:
jubnl
2026-04-14 23:50:52 +02:00
parent 85d72c831d
commit 4e3b27c712
6 changed files with 94 additions and 12 deletions
+7 -2
View File
@@ -1,6 +1,7 @@
import { create } from 'zustand'
import type { StoreApi } from 'zustand'
import { tripsApi, tagsApi, categoriesApi } from '../api/client'
import { offlineDb } from '../db/offlineDb'
import { tripRepo } from '../repo/tripRepo'
import { dayRepo } from '../repo/dayRepo'
import { placeRepo } from '../repo/placeRepo'
@@ -94,8 +95,12 @@ export const useTripStore = create<TripStoreState>((set, get) => ({
placeRepo.list(tripId),
packingRepo.list(tripId),
todoRepo.list(tripId),
tagsApi.list().catch(() => ({ tags: [] })),
categoriesApi.list().catch(() => ({ categories: [] })),
navigator.onLine
? tagsApi.list().catch(() => offlineDb.tags.toArray().then(tags => ({ tags })))
: offlineDb.tags.toArray().then(tags => ({ tags })),
navigator.onLine
? categoriesApi.list().catch(() => offlineDb.categories.toArray().then(categories => ({ categories })))
: offlineDb.categories.toArray().then(categories => ({ categories })),
])
const assignmentsMap: AssignmentsMap = {}