mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
drafts: Delete a draft if it is cleared from the compose box.
We used to keep the draft, assuming that clearing the composebox was an accident. Now we want to delete the draft, in preparation for auto-restoring drafts when opening the composebox for narrows with drafts associated with them. If a user opens the composebox and sees a draft they don't want anymore, clearing the box is a way we expect them to try to delete it.
This commit is contained in:
@@ -377,18 +377,18 @@ type UpdateDraftOptions = {
|
||||
export function update_draft(opts: UpdateDraftOptions = {}): string | undefined {
|
||||
const no_notify = opts.no_notify ?? false;
|
||||
const draft = snapshot_message();
|
||||
const draft_id = $("textarea#compose-textarea").data("draft-id");
|
||||
|
||||
if (draft === undefined) {
|
||||
// The user cleared the compose box, which means
|
||||
// there is nothing to save here. Don't obliterate
|
||||
// the existing draft yet--the user may have mistakenly
|
||||
// hit delete after select-all or something.
|
||||
// Just do nothing.
|
||||
// there is nothing to save here but delete the
|
||||
// draft if exists.
|
||||
if (draft_id) {
|
||||
draft_model.deleteDraft(draft_id);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const draft_id = $("textarea#compose-textarea").data("draft-id");
|
||||
|
||||
if (draft_id !== undefined) {
|
||||
// We don't save multiple drafts of the same message;
|
||||
// just update the existing draft.
|
||||
|
||||
Reference in New Issue
Block a user