mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
message_events: Ask server if cannot filter locally.
For filters that cannot be applied locally, we ask the server to determine if the `events_messages` are part of the narrow. Fixes #21073
This commit is contained in:
@@ -355,19 +355,26 @@ export function update_messages(events) {
|
|||||||
// this should be a loop over all valid message_list_data
|
// this should be a loop over all valid message_list_data
|
||||||
// objects, without the rerender (which will naturally
|
// objects, without the rerender (which will naturally
|
||||||
// happen in the following code).
|
// happen in the following code).
|
||||||
if (!changed_narrow) {
|
if (!changed_narrow && current_filter) {
|
||||||
let message_ids_to_remove = [];
|
let message_ids_to_remove = [];
|
||||||
if (current_filter && current_filter.can_apply_locally()) {
|
if (current_filter.can_apply_locally()) {
|
||||||
const predicate = current_filter.predicate();
|
const predicate = current_filter.predicate();
|
||||||
message_ids_to_remove = event_messages.filter((msg) => !predicate(msg));
|
message_ids_to_remove = event_messages.filter((msg) => !predicate(msg));
|
||||||
message_ids_to_remove = message_ids_to_remove.map((msg) => msg.id);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function do_unread_count_updates(messages) {
|
|||||||
resize.resize_page_components();
|
resize.resize_page_components();
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_messages(messages, msg_list, opts) {
|
export function add_messages(messages, msg_list, opts) {
|
||||||
if (!messages) {
|
if (!messages) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user