Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(mobile): keep checking uploads after status errors

Aditya Garudad218c015f50
diff --git a/apps/mobile/app/(tabs)/upload.tsx b/apps/mobile/app/(tabs)/upload.tsx
index 4e509d9a0..d583afda5 100644
--- a/apps/mobile/app/(tabs)/upload.tsx
+++ b/apps/mobile/app/(tabs)/upload.tsx
@@ -362,8 +362,16 @@ export default function UploadScreen() {
await new Promise((resolve) => setTimeout(resolve, delayMs));
if (!isActive()) return;
- const detail = await auth.client.getCap(capId);
+ const detail = await auth.client.getCap(capId).catch(() => null);
if (!isActive()) return;
+ if (!detail) {
+ dispatchIfMounted({
+ type: "processing",
+ id: queueItemId,
+ message: "Unable to check processing. Retrying...",
+ });
+ continue;
+ }
const action = uploadQueueActionFromCapUpload(
queueItemId,
detail.cap.upload,
diff --git a/apps/mobile/src/screens/dashboard-upload-visibility.test.tsx b/apps/mobile/src/screens/dashboard-upload-visibility.test.tsx
index 0654133cd..1acf4c473 100644
--- a/apps/mobile/src/screens/dashboard-upload-visibility.test.tsx
+++ b/apps/mobile/src/screens/dashboard-upload-visibility.test.tsx
@@ -1920,6 +1920,30 @@ describe("upload and dashboard visibility", () => {
},
);
+ it("keeps polling after a temporary status request failure", async () => {
+ auth.client.getCap = vi
+ .fn()
+ .mockRejectedValueOnce(new Error("Network unavailable"))
+ .mockResolvedValueOnce({ cap: { upload: null } });
+ const screen = await startImport();
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(1500);
+ });
+ expect(getTextNodes(screen.toJSON()).join(" ")).toContain(
+ "Unable to check processing. Retrying...",
+ );
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(3000);
+ });
+
+ expect(auth.client.getCap).toHaveBeenCalledTimes(2);
+ expect(getTextNodes(screen.toJSON()).join(" ")).toContain(
+ "Ready to view",
+ );
+ });
+
it.each(cancellations)(
"stops requests after %s while waiting",
async (reason) => {