From b80764264ae2e8d20ba02e6b94afc694082a91f2 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 26 Sep 2026 05:33:44 +0200 Subject: [PATCH] fix: reopen an undone send through the login that sent it In the classic layout an undo-send entry carries no login, and since 5f0669eb a draft opened without one is no longer stamped with the active login. When the user switched to another login inside the undo window and then clicked Undo, the send was cancelled on the right server, but the reopened draft's first save ran through the login now active and removed the old version by id there, where an unrelated message can have the same id. The undo toast now remembers the login that was active when the message was sent and reopens the draft through it. --- components/mail/mail-app.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/mail/mail-app.tsx b/components/mail/mail-app.tsx index a78887754..f3389ceae 100644 --- a/components/mail/mail-app.tsx +++ b/components/mail/mail-app.tsx @@ -2067,6 +2067,11 @@ export function MailApp({ linkSegments: routeSegments }: MailAppProps = {}) { const undoClient = pending.localAccountId ? (useAuthStore.getState().getClientForAccount(pending.localAccountId) ?? client) : client; + // The login the draft is restored through. The classic shell leaves + // `localAccountId` unset, and the user may switch logins before clicking + // Undo: without this, the draft's next save would run through the new + // active login and remove its old version by id in the wrong account. + const undoLogin = pending.localAccountId ?? useAuthStore.getState().activeAccountId ?? undefined; const undoDurationMs = Math.max(sendDelaySeconds, 8) * 1000; toast.success(t('email_viewer.scheduled_send_created'), { @@ -2117,7 +2122,7 @@ export function MailApp({ linkSegments: routeSegments }: MailAppProps = {}) { if (restored && !pending.isSmime) { // Back in the Drafts of the account it was sent from, through // the login that sent it. - await handleEditDraft(restored, { accountId: pending.submissionAccountId, localAccountId: pending.localAccountId }); + await handleEditDraft(restored, { accountId: pending.submissionAccountId, localAccountId: undoLogin }); } if (isScheduledView) await fetchScheduledEmails(client); } catch (error) {