mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
Avoid unnecessary fading/unfading processing via message_list.
The call to compose_fade.update_faded_messages() in message_list caused us to traverse every message in the current table, which was extremely inefficient. Now we call the newly created compose_fade.update_rendered_messages(), which only fades/unfades the messages passed in as the first parameter. (imported from commit a5a47e13fc9daeedd0899b2cfb02beb3f6b8cd0a)
This commit is contained in:
parent
ec2f013723
commit
beb89e247f
@ -110,6 +110,28 @@ exports.update_message_list = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.update_rendered_messages = function (messages, get_element) {
|
||||
if (_want_normal_display()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This loop is superficially similar to some code in _fade_messages, but an
|
||||
// important difference here is that we look at each message individually, whereas
|
||||
// the other code takes advantage of blocks beneath recipient bars.
|
||||
_.each(messages, function (message) {
|
||||
var elt = get_element(message);
|
||||
var should_fade_message = !util.same_recipient(focused_recipient, message);
|
||||
|
||||
if (should_fade_message) {
|
||||
elt.removeClass("unfaded").addClass("faded");
|
||||
} else {
|
||||
elt.removeClass("faded").addClass("unfaded");
|
||||
}
|
||||
});
|
||||
|
||||
ui.update_floating_recipient_bar();
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
}());
|
||||
|
||||
@ -621,8 +621,17 @@ MessageList.prototype = {
|
||||
this.select_id(this._selected_id, {from_rendering: true});
|
||||
}
|
||||
|
||||
// Re-add the fading of messages that is lost when we re-render.
|
||||
compose_fade.update_faded_messages();
|
||||
if (this === current_msg_list) {
|
||||
// We don't have a Message class, but we can at least hide the messy details
|
||||
// of rows.js from compose_fade. We provide a callback function to be lazy--
|
||||
// compose_fade may not actually need the elements depending on its internal
|
||||
// state.
|
||||
var get_element = function (message) {
|
||||
return rows.get(message.id, table_name);
|
||||
};
|
||||
|
||||
compose_fade.update_rendered_messages(messages, get_element);
|
||||
}
|
||||
|
||||
if (this === current_msg_list && messages_are_new) {
|
||||
this._maybe_autoscroll(rendered_elems);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user