message-list-view: Update sticky header in rerender_messages.

When a message list view rerenders a locally echoed message the
message recipient header is also rerendered, which then removes
the "sticky_header" class if it was present. If rerendering the
message triggers a non-user initiated scroll event, then the
"sticky_header" class is updated.

But it is possible that the rerendering of the message will not
trigger a scroll event, which means the recipient header is no
longer updated and the next calculation for the message list
view's _scroll_limit for the top of the feed will not include the
sticky header and the currently selected message may be scrolled
partially or completely under the message header recipient bar.

In message_list_view.rerender_messages, adds a check, after calling
_rerender_header in a loop, for the current message list and calls
update_sticky_recipient_headers if the message feed is visible.

Adds a comment to _rerender_header that we expect it to only be
called in rerender_messages so that the "sticky_header" class is
updated if needed.
This commit is contained in:
Lauryn Menard 2023-06-28 14:44:30 +02:00 committed by Tim Abbott
parent 07e199729c
commit 561902b180
1 changed files with 7 additions and 1 deletions

View File

@ -1208,7 +1208,9 @@ export class MessageListView {
_rerender_header(message_containers) { _rerender_header(message_containers) {
// Given a list of messages that are in the **same** message group, // Given a list of messages that are in the **same** message group,
// rerender the header / recipient bar of the messages // rerender the header / recipient bar of the messages. This method
// should only be called with rerender_messages as the rerendered
// header may need to be updated for the "sticky_header" class.
if (message_containers.length === 0) { if (message_containers.length === 0) {
return; return;
} }
@ -1315,6 +1317,10 @@ export class MessageListView {
for (const messages_in_group of message_groups) { for (const messages_in_group of message_groups) {
this._rerender_header(messages_in_group, message_content_edited); this._rerender_header(messages_in_group, message_content_edited);
} }
if (message_lists.current === this.list && narrow_state.is_message_feed_visible()) {
this.update_sticky_recipient_headers();
}
} }
append(messages, messages_are_new) { append(messages, messages_are_new) {