Skip to content

fix(email): Draft re-appears after send#1800

Merged
evanhutnik merged 1 commit intomainfrom
evan/draft-sticks-around
Mar 5, 2026
Merged

fix(email): Draft re-appears after send#1800
evanhutnik merged 1 commit intomainfrom
evan/draft-sticks-around

Conversation

@evanhutnik
Copy link
Copy Markdown
Contributor

Summary

  • Fix draft re-appearing after send: After sending a reply, navigating away from the thread, and coming back, the compose box would incorrectly restore the sent message as an active draft. This was caused by the undo-send snapshot (undoReplySnapshot) persisting at module level and being auto-restored on remount.
  • Ensure draft is always saved before send: Previously, if the user typed a reply and hit send before the 1-second debounce fired, no draft existed on the server, so undo-send had nothing to restore. Now we await executeSaveDraft() before sending to guarantee a draft ID always exists.
  • Fix undo-send after navigating away: The undo toast's onClick held a closure over the old component instance, so clicking undo after navigating away and back would unsend the message but fail to restore the compose box. Introduced a module-level restoreUndoCallback that the current component registers, allowing stale closures to reach the live component.

Changes

  • Split the single undoReplySnapshot into two module-level variables: undoSendSnapshot (set on send, consumed by undo) and undoReplySnapshot (only set by undo for inline reply remount)
  • Added restoreUndoCallback pattern so undo-send works correctly across component remounts
  • Deferred restore via setTimeout to let reactive updates from setQueryData settle before restoring attachments
  • Removed redundant executeSaveDraft() call in the scheduled send path since draft is now always saved before send

@evanhutnik evanhutnik requested a review from a team as a code owner March 5, 2026 21:06
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

@evanhutnik evanhutnik merged commit dea6e2d into main Mar 5, 2026
23 checks passed
@evanhutnik evanhutnik deleted the evan/draft-sticks-around branch March 5, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant