mirror of https://github.com/zulip/zulip.git
navigate: Correct handling of limited fetched content.
This correctly avoids pageup/pagedown scrolling past already rendered
content, while also always making progress, which the previous logic
introduced in d8ec141de2
might do, at
least in degenerate cases with very small render windows.
I'm not sure this change has any effect in practice with current
render window values, but it does fix a bug if I set the maximum
render window size to 20.
This commit is contained in:
parent
b9af5ce86e
commit
a8698c08ca
|
@ -1439,6 +1439,10 @@ export class MessageListView {
|
||||||
this.message_containers.clear();
|
this.message_containers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_rendered_message() {
|
||||||
|
return this.list.data._items[this._render_win_end - 1];
|
||||||
|
}
|
||||||
|
|
||||||
is_fetched_end_rendered() {
|
is_fetched_end_rendered() {
|
||||||
return this._render_win_end === this.list.num_items();
|
return this._render_win_end === this.list.num_items();
|
||||||
}
|
}
|
||||||
|
@ -1452,6 +1456,10 @@ export class MessageListView {
|
||||||
return this.is_fetched_end_rendered() && this.list.data.fetch_status.has_found_newest();
|
return this.is_fetched_end_rendered() && this.list.data.fetch_status.has_found_newest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
first_rendered_message() {
|
||||||
|
return this.list.data._items[this._render_win_start];
|
||||||
|
}
|
||||||
|
|
||||||
is_fetched_start_rendered() {
|
is_fetched_start_rendered() {
|
||||||
return this._render_win_start === 0;
|
return this._render_win_start === 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,24 +100,31 @@ export function page_down_the_right_amount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function page_up() {
|
export function page_up() {
|
||||||
if (
|
if (message_viewport.at_rendered_top() && !message_lists.current.visibly_empty()) {
|
||||||
message_viewport.at_rendered_top() &&
|
if (message_lists.current.view.is_fetched_start_rendered()) {
|
||||||
!message_lists.current.visibly_empty() &&
|
message_lists.current.select_id(message_lists.current.first().id, {then_scroll: false});
|
||||||
message_lists.current.view.is_fetched_start_rendered()
|
} else {
|
||||||
) {
|
message_lists.current.select_id(
|
||||||
message_lists.current.select_id(message_lists.current.first().id, {then_scroll: false});
|
message_lists.current.view.first_rendered_message().id,
|
||||||
|
{
|
||||||
|
then_scroll: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
page_up_the_right_amount();
|
page_up_the_right_amount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function page_down() {
|
export function page_down() {
|
||||||
if (
|
if (message_viewport.at_rendered_bottom() && !message_lists.current.visibly_empty()) {
|
||||||
message_viewport.at_rendered_bottom() &&
|
if (message_lists.current.view.is_fetched_end_rendered()) {
|
||||||
!message_lists.current.visibly_empty() &&
|
message_lists.current.select_id(message_lists.current.last().id, {then_scroll: false});
|
||||||
message_lists.current.view.is_fetched_end_rendered()
|
} else {
|
||||||
) {
|
message_lists.current.select_id(message_lists.current.view.last_rendered_message().id, {
|
||||||
message_lists.current.select_id(message_lists.current.last().id, {then_scroll: false});
|
then_scroll: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
unread_ops.process_visible();
|
unread_ops.process_visible();
|
||||||
} else {
|
} else {
|
||||||
page_down_the_right_amount();
|
page_down_the_right_amount();
|
||||||
|
|
Loading…
Reference in New Issue