mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-01 00:13:37 +00:00
fix: clear the viewer when sending destroys the displayed draft
Sending an edited draft destroys it server-side, but the viewer kept rendering the deleted message after the composer closed: the mailbox list refreshed (row gone, counter down) while selectedEmail still pointed at the destroyed draft. Clear the selection like a delete does - and return to the list on mobile - when the email on display is the draft the compose session was opened from or its latest autosaved successor (autosave replaces the draft under a fresh id on every save, so matching the sent draftId alone would miss).
This commit is contained in:
@@ -1537,6 +1537,15 @@ export function MailApp({ linkSegments }: MailAppProps = {}) {
|
||||
const result = await sendEmail(sendClient, data.to, data.subject, data.body, data.cc, data.bcc, data.identityId, data.fromEmail, data.draftId, data.fromName, data.htmlBody, data.attachments, data.inReplyTo, data.references, data.delayedUntil, data.envelopeMailFrom, { requestReadReceipt: data.requestReadReceipt, localAccountId: data.localAccountId });
|
||||
submitted = true;
|
||||
setShowComposer(false);
|
||||
// Sending an edited draft destroys it server-side - and every autosave
|
||||
// before that already replaced it under a fresh id (createDraft is a
|
||||
// destroy+create). If the email on display is the draft this session
|
||||
// was opened from, or its latest autosaved successor, clear the
|
||||
// selection like a delete does.
|
||||
if (selectedEmail && (selectedEmail.id === data.draftId || selectedEmail.id === pendingDraft?.draftId)) {
|
||||
selectEmail(null);
|
||||
if (isMobile) setActiveView('list');
|
||||
}
|
||||
if (result.filingError) {
|
||||
// The mail went out, but a post-send step (filing to Sent /
|
||||
// removing the old draft) was rejected - warn instead of staying
|
||||
|
||||
Reference in New Issue
Block a user