refactor: Rename `delete_draft_after_send` to `delete_active_draft`.

This commit renames `delete_draft_after_send` to
`delete_active_draft` for two main reasons:

1) This function does the job of deleting the draft that we
are currently using in compose box and it is independent
of the message sending functionality.

2) This is prep refactoring for new drafts behavior where
we delete the draft if the compose box is cleared and
closed.
This commit is contained in:
Riken Shah 2021-05-31 18:53:52 +00:00 committed by Tim Abbott
parent 44c25619d7
commit 38d9e26a6c
3 changed files with 4 additions and 4 deletions

View File

@ -352,7 +352,7 @@ test_ui("markdown_shortcuts", (override) => {
});
test_ui("send_message_success", (override) => {
override(drafts, "delete_draft_after_send", () => {});
override(drafts, "delete_active_draft", () => {});
$("#compose-textarea").val("foobarfoobar");
$("#compose-textarea").trigger("blur");
@ -381,7 +381,7 @@ test_ui("send_message_success", (override) => {
test_ui("send_message", (override) => {
MockDate.set(new Date(fake_now * 1000));
override(drafts, "delete_draft_after_send", () => {});
override(drafts, "delete_active_draft", () => {});
override(sent_messages, "start_tracking_message", () => {});
// This is the common setup stuff for all of the four tests.

View File

@ -289,7 +289,7 @@ function compose_not_subscribed_error(error_html, bad_input) {
export function clear_compose_box() {
$("#compose-textarea").val("").trigger("focus");
drafts.delete_draft_after_send();
drafts.delete_active_draft();
compose_ui.autosize_textarea($("#compose-textarea"));
$("#compose-send-status").hide(0);
$("#compose-send-button").prop("disabled", false);

View File

@ -180,7 +180,7 @@ export function update_draft() {
draft_notify();
}
export function delete_draft_after_send() {
export function delete_active_draft() {
const draft_id = $("#compose-textarea").data("draft-id");
if (draft_id) {
draft_model.deleteDraft(draft_id);