Archived
Add offline caching and refine Live Activity
This commit is contained in:
@@ -126,6 +126,16 @@ httpBatchLink({
|
||||
|
||||
Query defaults: `staleTime: 30_000`, `retry: 1`. Usage: `import { api } from "@/lib/trpc"`.
|
||||
|
||||
## Offline mode
|
||||
|
||||
Read queries are cached per account + API URL in AsyncStorage (`lib/offline-cache.ts`). `TRPCProvider` restores that cache before mounting app screens, then persists successful query data for up to 7 days. SuperJSON is used for persistence so API payloads keep Date values and other transformed types.
|
||||
|
||||
`lib/network-status.ts` connects `expo-network` to TanStack Query's `onlineManager`. When the device is offline, queries pause instead of repeatedly failing; when connectivity returns, React Query reconnect behavior refreshes stale data. The better-auth Expo client also keeps its SecureStore session cache enabled so a previously signed-in account can get through app boot while offline, then reconcile with the server when connectivity returns.
|
||||
|
||||
Account removal clears that account's persisted query cache alongside SecureStore auth and time-clock preferences.
|
||||
|
||||
Current offline scope: previously loaded dashboard, invoices, clients, businesses, expenses, reports, recurring invoices, and time entries can be viewed offline from cache. Mutations still require the API; timer actions, invoice edits/status changes, receipt uploads, reminders, emails, and onboarding writes are not persisted as an offline queue yet because they need conflict and side-effect rules.
|
||||
|
||||
## App lock (per account)
|
||||
|
||||
`lib/app-lock.ts` — SecureStore keys scoped by `activeAccountId`:
|
||||
|
||||
Reference in New Issue
Block a user