Add offline caching and refine Live Activity

This commit is contained in:
2026-08-14 16:26:43 -04:00
parent fa3b9bf6a0
commit 31ae51cf9e
12 changed files with 392 additions and 21 deletions
+25 -2
View File
@@ -11,16 +11,39 @@ import {
type AuthClient = ReturnType<typeof createAuthClient>;
async function authFetch(input: RequestInfo | URL, init?: RequestInit) {
try {
return await fetch(input, init);
} catch (error) {
if (error instanceof Error && error.name === "AbortError") {
throw error;
}
return new Response(
JSON.stringify({
message: "Could not connect to the server.",
code: "NETWORK_ERROR",
}),
{
status: 503,
statusText: "Service Unavailable",
headers: { "content-type": "application/json" },
},
);
}
}
function createAppAuthClient(apiUrl: string, storagePrefix: string): AuthClient {
return createAuthClient({
baseURL: apiUrl,
fetchOptions: {
customFetchImpl: authFetch,
},
plugins: [
expoClient({
scheme: "beenvoice",
storagePrefix,
storage: SecureStore,
// Avoid showing a cached session when cookies have already expired.
disableCache: true,
}),
genericOAuthClient(),
],