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 <bablinaneh@gmail.com>
This commit is contained in:
Sahil Singh 2023-03-14 15:19:33 +05:30 committed by Tim Abbott
parent 67f2bc030f
commit 7ecb63c332
2 changed files with 5 additions and 6 deletions

View File

@ -253,15 +253,15 @@ export function start(msg_type, opts) {
compose_state.message_content(opts.content); 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); compose_state.set_message_type(msg_type);
// Show either stream/topic fields or "You and" field. // Show either stream/topic fields or "You and" field.
show_compose_box(msg_type, opts); 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 // Show a warning if topic is resolved
compose_validate.warn_if_topic_resolved(true); compose_validate.warn_if_topic_resolved(true);

View File

@ -284,7 +284,7 @@ export function restore_draft(draft_id) {
return; return;
} }
const compose_args = restore_message(draft); const compose_args = {...restore_message(draft), draft_id};
if (compose_args.type === "stream") { if (compose_args.type === "stream") {
if (draft.stream_id !== "" && draft.topic !== "") { if (draft.stream_id !== "" && draft.topic !== "") {
@ -309,7 +309,6 @@ export function restore_draft(draft_id) {
compose.clear_preview_area(); compose.clear_preview_area();
compose_actions.start(compose_args.type, compose_args); compose_actions.start(compose_args.type, compose_args);
compose_ui.autosize_textarea($("#compose-textarea")); compose_ui.autosize_textarea($("#compose-textarea"));
$("#compose-textarea").data("draft-id", draft_id);
compose_validate.check_overflow_text(); compose_validate.check_overflow_text();
} }