fix(offline): load trips from Dexie on dashboard when offline; fix offline tab i18n key

This commit is contained in:
jubnl
2026-04-14 23:34:28 +02:00
parent d3b5ca451b
commit bb3543efa6
17 changed files with 36 additions and 7 deletions
+17
View File
@@ -3,6 +3,23 @@ import { offlineDb, upsertTrip } from '../db/offlineDb'
import type { Trip } from '../types'
export const tripRepo = {
async list(): Promise<{ trips: Trip[]; archivedTrips: Trip[] }> {
if (!navigator.onLine) {
const all = await offlineDb.trips.toArray()
return {
trips: all.filter(t => !t.is_archived),
archivedTrips: all.filter(t => t.is_archived),
}
}
const [active, archived] = await Promise.all([
tripsApi.list(),
tripsApi.list({ archived: 1 }),
])
active.trips.forEach(t => upsertTrip(t))
archived.trips.forEach(t => upsertTrip(t))
return { trips: active.trips, archivedTrips: archived.trips }
},
async get(tripId: number | string): Promise<{ trip: Trip }> {
if (!navigator.onLine) {
const cached = await offlineDb.trips.get(Number(tripId))