From 7ecb63c3327871b5f3eebb10ae80a4a55eae143b Mon Sep 17 00:00:00 2001 From: Sahil Singh Date: Tue, 14 Mar 2023 15:19:33 +0530 Subject: [PATCH] drafts: Pass draft_id to compose_actions.start as part of compose_args. This will allow us to remove some duplicated compose box code that was previously inside restore_draft. Co-authored-by: N-Shar-ma --- web/src/compose_actions.js | 8 ++++---- web/src/drafts.js | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/web/src/compose_actions.js b/web/src/compose_actions.js index 6b39869bb7..b0f9c7da24 100644 --- a/web/src/compose_actions.js +++ b/web/src/compose_actions.js @@ -253,15 +253,15 @@ export function start(msg_type, opts) { compose_state.message_content(opts.content); } - if (opts.draft_id) { - $("#compose-textarea").data("draft-id", opts.draft_id); - } - compose_state.set_message_type(msg_type); // Show either stream/topic fields or "You and" field. show_compose_box(msg_type, opts); + if (opts.draft_id) { + $("#compose-textarea").data("draft-id", opts.draft_id); + } + // Show a warning if topic is resolved compose_validate.warn_if_topic_resolved(true); diff --git a/web/src/drafts.js b/web/src/drafts.js index 07bb5bc54a..8ad1355061 100644 --- a/web/src/drafts.js +++ b/web/src/drafts.js @@ -284,7 +284,7 @@ export function restore_draft(draft_id) { return; } - const compose_args = restore_message(draft); + const compose_args = {...restore_message(draft), draft_id}; if (compose_args.type === "stream") { if (draft.stream_id !== "" && draft.topic !== "") { @@ -309,7 +309,6 @@ export function restore_draft(draft_id) { compose.clear_preview_area(); compose_actions.start(compose_args.type, compose_args); compose_ui.autosize_textarea($("#compose-textarea")); - $("#compose-textarea").data("draft-id", draft_id); compose_validate.check_overflow_text(); }