Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
refactor: Extract update message flags POST call.
Abhijeet Prasad Bodasaa0e5dd35be1
diff --git a/static/js/message_flags.js b/static/js/message_flags.jsindex 16f16ccfd02..54507e57f51 100644--- a/static/js/message_flags.js+++ b/static/js/message_flags.js@@ -6,12 +6,12 @@ import * as starred_messages from "./starred_messages";import * as ui from "./ui";import * as unread_ops from "./unread_ops";-function send_flag_update(message, flag, op) {+function send_flag_update_for_messages(msg_ids, flag, op) {channel.post({url: "/json/messages/flags",idempotent: true,data: {- messages: JSON.stringify([message.id]),+ messages: JSON.stringify(msg_ids),flag,op,},@@ -69,11 +69,11 @@ export const send_read = (function () {})();export function save_collapsed(message) {- send_flag_update(message, "collapsed", "add");+ send_flag_update_for_messages([message.id], "collapsed", "add");}export function save_uncollapsed(message) {- send_flag_update(message, "collapsed", "remove");+ send_flag_update_for_messages([message.id], "collapsed", "remove");}// This updates the state of the starred flag in local data@@ -108,23 +108,15 @@ export function toggle_starred_and_update_server(message) {ui.update_starred_view(message.id, message.starred);if (message.starred) {- send_flag_update(message, "starred", "add");+ send_flag_update_for_messages([message.id], "starred", "add");starred_messages.add([message.id]);} else {- send_flag_update(message, "starred", "remove");+ send_flag_update_for_messages([message.id], "starred", "remove");starred_messages.remove([message.id]);}}export function unstar_all_messages() {const starred_msg_ids = starred_messages.get_starred_msg_ids();- channel.post({- url: "/json/messages/flags",- idempotent: true,- data: {- messages: JSON.stringify(starred_msg_ids),- flag: "starred",- op: "remove",- },- });+ send_flag_update_for_messages(starred_msg_ids, "starred", "remove");}