mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 14:21:46 +00:00
fix: decouple IDB writes from network-data return path
QuotaExceededError from a full IndexedDB was being caught by the IIFE's
try/catch (after the earlier await-upsert change), causing repos to return
null/empty even when the network fetch succeeded. Fire-and-forget upserts
with .catch(()=>{}) ensure write failures never suppress fetched data.
This commit is contained in:
@@ -11,7 +11,7 @@ export const accommodationRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await accommodationsApi.list(tripId)
|
||||
await upsertAccommodations(result.accommodations || [])
|
||||
upsertAccommodations(result.accommodations || []).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const budgetRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await budgetApi.list(tripId)
|
||||
await upsertBudgetItems(result.items)
|
||||
upsertBudgetItems(result.items).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const dayRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await daysApi.list(tripId)
|
||||
await upsertDays(result.days)
|
||||
upsertDays(result.days).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const fileRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await filesApi.list(tripId)
|
||||
await upsertTripFiles(result.files)
|
||||
upsertTripFiles(result.files).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const packingRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await packingApi.list(tripId)
|
||||
await upsertPackingItems(result.items)
|
||||
upsertPackingItems(result.items).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const placeRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await placesApi.list(tripId, params)
|
||||
await upsertPlaces(result.places)
|
||||
upsertPlaces(result.places).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const reservationRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await reservationsApi.list(tripId)
|
||||
await upsertReservations(result.reservations)
|
||||
upsertReservations(result.reservations).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -13,7 +13,7 @@ export const todoRepo = {
|
||||
const refresh = (async () => {
|
||||
try {
|
||||
const result = await todoApi.list(tripId)
|
||||
await upsertTodoItems(result.items)
|
||||
upsertTodoItems(result.items).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -16,10 +16,10 @@ export const tripRepo = {
|
||||
tripsApi.list(),
|
||||
tripsApi.list({ archived: 1 }),
|
||||
])
|
||||
await Promise.all([
|
||||
Promise.all([
|
||||
...active.trips.map(t => upsertTrip(t)),
|
||||
...archived.trips.map(t => upsertTrip(t)),
|
||||
])
|
||||
]).catch(() => {})
|
||||
return { trips: active.trips, archivedTrips: archived.trips }
|
||||
} catch {
|
||||
return null
|
||||
@@ -46,7 +46,7 @@ export const tripRepo = {
|
||||
const refresh: TripRefresh = (async () => {
|
||||
try {
|
||||
const result = await tripsApi.get(tripId)
|
||||
await upsertTrip(result.trip)
|
||||
upsertTrip(result.trip).catch(() => {})
|
||||
return result
|
||||
} catch {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user