Skip to content

Commit c8706d7

Browse files
fix(mobile): a PDF closed as its download finishes still discards the copy, and gallery URL refreshes stop on close
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bea7379 commit c8706d7

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/mobile/src/components/FilePreviewModal.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function resolvePreviewItem(
5353
}
5454
if (!("environmentId" in item)) return { source: { ...item, name } };
5555
// Refresh expired URLs before handing them to Quick Look or ACTION_VIEW, which retain them.
56-
const url = await refreshAssetUrl(item.environmentId, item.resource)
56+
const url = await refreshAssetUrl(item.environmentId, item.resource, signal)
5757
.then((value) => {
5858
if (!value) throw new Error("Reconnect to this environment and try again.");
5959
return value;

‎apps/mobile/src/components/PdfPreview.android.tsx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ const preparedPdfAtom = Atom.family((uri: string) =>
1818
// stays interruptible so closing the viewer aborts the download.
1919
Effect.acquireRelease(
2020
Effect.tryPromise({
21-
try: (signal) => preparePdfPreview(uri, signal),
21+
try: (signal) => {
22+
const prepared = preparePdfPreview(uri, signal);
23+
// An interrupt can land after the copy exists but before acquireRelease owns it.
24+
signal.addEventListener("abort", () => {
25+
void prepared.then(
26+
(file) => file?.dispose(),
27+
() => undefined,
28+
);
29+
});
30+
return prepared;
31+
},
2232
catch: (cause) => (cause instanceof Error ? cause.message : "The PDF could not be loaded."),
2333
}).pipe(
2434
Effect.flatMap((file) => (file === null ? Effect.interrupt : Effect.succeed(file))),

0 commit comments

Comments
 (0)