Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/mobile/src/features/home/useThreadListActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,19 @@ describe("thread action undo", () => {
expect(state.requests.map(({ action }) => action)).toEqual(["archive"]);
expect(state.archivedRefreshes).toEqual([primaryEnvironmentId]);
});

it("keeps the earlier Undo until archiving succeeds", async () => {
const actions = useThreadListActions();
const thread = makeThread();
await actions.settleThread(thread);
state.failedAction = "archive";
expect(await actions.archiveThread(thread)).toBe(false);
expect(readThreadUndoNotice()?.action).toBe("Settled");

state.failedAction = null;
expect(await actions.archiveThread(thread)).toBe(true);
expect(readThreadUndoNotice()).toBeNull();
});
});

describe("thread archive guard", () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/src/features/home/useThreadListActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ function useThreadActionExecutor(
return false;
}
if (action === "unsettle") ThreadUndo.invalidate("settle", key);
if (action === "archive" || action === "delete") {
for (const kind of ["settle", "snooze", "pin"]) ThreadUndo.invalidate(kind, key);
}
onStarted?.();
const result = await withThreadDismissal(
key,
Expand Down Expand Up @@ -157,6 +154,9 @@ function useThreadActionExecutor(
Dialog.alert(actionFailureTitle(action), actionFailureMessage(action, result.cause));
return false;
}
if (action === "archive" || action === "delete") {
Comment thread
saphid marked this conversation as resolved.
Resolved
for (const kind of ["settle", "snooze", "pin"]) ThreadUndo.invalidate(kind, key);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
if (action === "archive" || action === "unarchive" || action === "delete") {
refreshArchivedThreadsForEnvironment(thread.environmentId);
}
Expand Down
Loading