fix(webmail): Discard really discards the draft

The button was a link to the inbox, so the autosaved draft stayed in Drafts.
It now removes the stored draft for good (not into Trash), stops the autosave,
and cleans up a save that was already in flight.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-10-22 16:02:27 -03:00
1 parent d283ff6f8d
commit 657a43d612
8 files changed
+132 -8

No files matched your search

@@ -283,6 +283,20 @@ func (uc *WebmailUseCase) Delete(ctx context.Context, address, folder string, ui
}
}
// DiscardDraft removes a draft for good.
//
// Delete would move it to Trash, which is right for a message someone might
// want back and wrong for "Discard": the composer's button promises the draft
// is gone, and one waiting in Trash is a draft that is not. Only Drafts is
// reachable from here, so this cannot be used to expunge anything else.
func (uc *WebmailUseCase) DiscardDraft(ctx context.Context, address string, uid uint32) error {
mailboxID, err := uc.mailboxID(ctx, address)
if err != nil {
return err
}
return uc.repo.Expunge(ctx, mailboxID, "Drafts", uid)
}
// SaveDraft files the message being composed into the Drafts folder.
//
// Nothing did this before: the composer displayed "draft saved automatically"