Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

thread-triage-outbox-storage.ts

20 lines801 Bytes

1import {
2 makeThreadTriageOutboxStore,
3 ThreadTriageOutboxStorageError,
4} from "@t3tools/client-runtime/platform";
5import * as Effect from "effect/Effect";
6​
7import { writeFileAtomically } from "../lib/atomic-file";
8​
9/** A file outside the client cache, so clearing cached data keeps unsynced settles and snoozes. */
10export const mobileThreadTriageOutboxStore = makeThreadTriageOutboxStore((next) =>
11 Effect.tryPromise({
12 try: async () => {
13 const { File, Paths } = await import("expo-file-system");
14 const file = new File(Paths.document, "thread-triage-outbox.json");
15 const value = next(file.exists ? await file.text() : null);
16 if (value !== null) await writeFileAtomically(file, value);
17 },
18 catch: (cause) => new ThreadTriageOutboxStorageError({ cause }),
19 }),
20);