Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_events: Ask server if cannot filter locally.
Aman Agrawalbda90ec5ae6e
diff --git a/static/js/message_events.js b/static/js/message_events.jsindex a994b68d08d..6882117731e 100644--- a/static/js/message_events.js+++ b/static/js/message_events.js@@ -355,19 +355,26 @@ export function update_messages(events) {// this should be a loop over all valid message_list_data// objects, without the rerender (which will naturally// happen in the following code).- if (!changed_narrow) {+ if (!changed_narrow && current_filter) {let message_ids_to_remove = [];- if (current_filter && current_filter.can_apply_locally()) {+ if (current_filter.can_apply_locally()) {const predicate = current_filter.predicate();message_ids_to_remove = event_messages.filter((msg) => !predicate(msg));message_ids_to_remove = message_ids_to_remove.map((msg) => msg.id);+ // We filter out messages that do not belong to the message+ // list and then pass these to the remove messages codepath.+ // While we can pass all our messages to the add messages+ // codepath as the filtering is done within the method.+ message_lists.current.remove_and_rerender(message_ids_to_remove);+ message_lists.current.add_messages(event_messages);+ } else {+ // For filters that cannot be processed locally, ask server.+ maybe_add_narrowed_messages(+ event_messages,+ message_lists.current,+ message_util.add_messages,+ );}- // We filter out messages that do not belong to the message- // list and then pass these to the remove messages codepath.- // While we can pass all our messages to the add messages- // codepath as the filtering is done within the method.- message_lists.current.remove_and_rerender(message_ids_to_remove);- message_lists.current.add_messages(event_messages);}}diff --git a/static/js/message_util.js b/static/js/message_util.jsindex 5ced5c23016..56e085b60a3 100644--- a/static/js/message_util.js+++ b/static/js/message_util.js@@ -13,7 +13,7 @@ export function do_unread_count_updates(messages) {resize.resize_page_components();}-function add_messages(messages, msg_list, opts) {+export function add_messages(messages, msg_list, opts) {if (!messages) {return undefined;}