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.

message_list: Don't rerender if no messages were removed.

Aman Agrawal6ca04056dcf7
diff --git a/web/src/message_list.ts b/web/src/message_list.ts
index e25c7f14e13..b57c46d1106 100644
--- a/web/src/message_list.ts
+++ b/web/src/message_list.ts
@@ -496,7 +496,10 @@ export class MessageList {
}
remove_and_rerender(message_ids: number[]): void {
- this.data.remove(message_ids);
+ const should_rerender = this.data.remove(message_ids);
+ if (!should_rerender) {
+ return;
+ }
this.rerender();
// Rebuild message list if we're deleting messages from the current list,
// since we might need to remove a participant user.
diff --git a/web/src/message_list_data.ts b/web/src/message_list_data.ts
index 494bd074d9b..fa80d6c203e 100644
--- a/web/src/message_list_data.ts
+++ b/web/src/message_list_data.ts
@@ -384,15 +384,22 @@ export class MessageListData {
return viewable_messages;
}
- remove(message_ids: number[]): void {
+ remove(message_ids: number[]): boolean {
const msg_ids_to_remove = new Set(message_ids);
+ let found_any_msgs_to_remove = false;
for (const id of msg_ids_to_remove) {
- this._hash.delete(id);
- this._local_only.delete(id);
+ const found_in_hash = this._hash.delete(id);
+ const found_in_local_only = this._local_only.delete(id);
+
+ if (!found_any_msgs_to_remove && (found_in_hash || found_in_local_only)) {
+ found_any_msgs_to_remove = true;
+ }
}
this._items = this._items.filter((msg) => !msg_ids_to_remove.has(msg.id));
this._all_items = this._all_items.filter((msg) => !msg_ids_to_remove.has(msg.id));
+
+ return found_any_msgs_to_remove;
}
// Returns messages from the given message list in the specified range, inclusive