mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
message_util: Avoid unnecessary unreads work processing new messages.
It should be very rare to discover new unread messages during a message_fetch call. This can potentially happen due to races (fetching just as a new message arrives), but it shouldn't be the common case. Previously, we would trigger a full rerender of all UI displaying unread messages every time a bulk message fetch operation returned (including every time one narrowed), regardless of whether any actual state had changed. Fix this by actually checking if we discovered any new unread messages.
This commit is contained in:
@@ -7,10 +7,15 @@ import * as resize from "./resize";
|
||||
import * as unread from "./unread";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
|
||||
export function do_unread_count_updates(messages) {
|
||||
unread.process_loaded_messages(messages);
|
||||
unread_ui.update_unread_counts();
|
||||
resize.resize_page_components();
|
||||
export function do_unread_count_updates(messages, expect_no_new_unreads = false) {
|
||||
const any_new_unreads = unread.process_loaded_messages(messages, expect_no_new_unreads);
|
||||
|
||||
if (any_new_unreads) {
|
||||
// The following operations are expensive, and thus should
|
||||
// only happen if we found any unread messages justifying it.
|
||||
unread_ui.update_unread_counts();
|
||||
resize.resize_page_components();
|
||||
}
|
||||
}
|
||||
|
||||
export function add_messages(messages, msg_list, opts) {
|
||||
|
||||
Reference in New Issue
Block a user