mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
drafts: Extract maybe_notify function in update_draft.
This is a prep commit for adding node test coverage to drafts.update_draft().
This commit is contained in:
@@ -175,6 +175,12 @@ function draft_notify() {
|
||||
setTimeout(remove_instance, 3000);
|
||||
}
|
||||
|
||||
function maybe_notify(no_notify) {
|
||||
if (!no_notify) {
|
||||
draft_notify();
|
||||
}
|
||||
}
|
||||
|
||||
export function update_draft(opts = {}) {
|
||||
const no_notify = opts.no_notify || false;
|
||||
const draft = snapshot_message();
|
||||
@@ -194,9 +200,7 @@ export function update_draft(opts = {}) {
|
||||
// We don't save multiple drafts of the same message;
|
||||
// just update the existing draft.
|
||||
draft_model.editDraft(draft_id, draft);
|
||||
if (!no_notify) {
|
||||
draft_notify();
|
||||
}
|
||||
maybe_notify(no_notify);
|
||||
return draft_id;
|
||||
}
|
||||
|
||||
@@ -204,9 +208,7 @@ export function update_draft(opts = {}) {
|
||||
// one.
|
||||
const new_draft_id = draft_model.addDraft(draft);
|
||||
$("#compose-textarea").data("draft-id", new_draft_id);
|
||||
if (!no_notify) {
|
||||
draft_notify();
|
||||
}
|
||||
maybe_notify(no_notify);
|
||||
|
||||
return new_draft_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user