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:
1 parent
d283ff6f8d
commit
657a43d612
8 files changed
+132
-8
No files matched your search
@@ -300,6 +300,8 @@ func (m *mailAPI) handleDelete(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
Folder string `json:"folder"`
|
||||
UID uint32 `json:"uid"`
|
||||
// DiscardDraft removes a draft for good instead of moving it to Trash.
|
||||
DiscardDraft bool `json:"discard_draft"`
|
||||
}
|
||||
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4096)).Decode(&body); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "BAD_REQUEST", "Invalid JSON")
|
||||
@@ -313,6 +315,15 @@ func (m *mailAPI) handleDelete(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if body.DiscardDraft {
|
||||
if err := m.useCase.DiscardDraft(r.Context(), session.Email, body.UID); err != nil {
|
||||
m.fail(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]bool{"deleted": true})
|
||||
return
|
||||
}
|
||||
|
||||
if err := m.useCase.Delete(r.Context(), session.Email, body.Folder, body.UID); err != nil {
|
||||
m.fail(w, err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user