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.
This commit is contained in:
Linus Rath
2026-09-26 05:33:44 +02:00
parent 219ea22276
commit b80764264a
+6 -1
View File
@@ -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) {