mirror of https://github.com/zulip/zulip.git
message_list_view: Recalculate more fields for _rerender_message.
Previously, we used to only calculate sender_is_bot, sender_is_guest, small_avatar_url and background_color on the message_container via build_message_groups (ie via .render, which also gets called from .rerender_with_target_scrolltop). This would mean that if we tried to use `_rerender_message` to update just a single message (which is something we'd like to do, in order to make rerenders more efficient), these values would not update. (This could lead to avatars not light-updating properly). As such, this commit moves assignment of these values into `set_calculated_message_container_variables`.
This commit is contained in:
parent
a800a86f54
commit
33f9e83588
|
@ -44,6 +44,12 @@ mock_esm("../../static/js/rows", {
|
|||
},
|
||||
});
|
||||
|
||||
mock_esm("../../static/js/people", {
|
||||
sender_is_bot: () => false,
|
||||
sender_is_guest: () => false,
|
||||
small_avatar_url: () => "fake/small/avatar/url",
|
||||
});
|
||||
|
||||
const {Filter} = zrequire("../js/filter");
|
||||
const {MessageListView} = zrequire("../js/message_list_view");
|
||||
const message_list = zrequire("message_list");
|
||||
|
@ -283,6 +289,11 @@ test("muted_message_vars", () => {
|
|||
// Sender is not muted.
|
||||
let result = calculate_variables(list, messages);
|
||||
|
||||
// sanity check on mocked values
|
||||
assert.equal(result[1].sender_is_bot, false);
|
||||
assert.equal(result[1].sender_is_guest, false);
|
||||
assert.equal(result[1].small_avatar_url, "fake/small/avatar/url");
|
||||
|
||||
// Check that `is_hidden` is false on all messages, and `include_sender` has not changed.
|
||||
assert.equal(result[0].is_hidden, false);
|
||||
assert.equal(result[1].is_hidden, false);
|
||||
|
|
|
@ -295,6 +295,16 @@ export class MessageListView {
|
|||
message_container.include_sender = true;
|
||||
}
|
||||
|
||||
message_container.sender_is_bot = people.sender_is_bot(message_container.msg);
|
||||
message_container.sender_is_guest = people.sender_is_guest(message_container.msg);
|
||||
|
||||
message_container.small_avatar_url = people.small_avatar_url(message_container.msg);
|
||||
if (message_container.msg.stream) {
|
||||
message_container.background_color = stream_data.get_color(
|
||||
message_container.msg.stream,
|
||||
);
|
||||
}
|
||||
|
||||
this._maybe_format_me_message(message_container);
|
||||
// Once all other variables are updated
|
||||
this._add_msg_edited_vars(message_container);
|
||||
|
@ -411,16 +421,6 @@ export class MessageListView {
|
|||
message_container.include_sender = false;
|
||||
}
|
||||
|
||||
message_container.sender_is_bot = people.sender_is_bot(message_container.msg);
|
||||
message_container.sender_is_guest = people.sender_is_guest(message_container.msg);
|
||||
|
||||
message_container.small_avatar_url = people.small_avatar_url(message_container.msg);
|
||||
if (message_container.msg.stream) {
|
||||
message_container.background_color = stream_data.get_color(
|
||||
message_container.msg.stream,
|
||||
);
|
||||
}
|
||||
|
||||
this.set_calculated_message_container_variables(message_container);
|
||||
|
||||
prev = message_container;
|
||||
|
|
Loading…
Reference in New Issue