Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

drafts: Extract maybe_notify function in update_draft.

YashRE42c8f18f8ae78e
diff --git a/static/js/drafts.js b/static/js/drafts.js
index 33c9cb2e994..e45274d334a 100644
--- a/static/js/drafts.js
+++ b/static/js/drafts.js
@@ -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;
}