From 42956e03056e3dc2ce8d26b55740b625c0a8f706 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 31 Jan 2024 13:44:33 -0800 Subject: [PATCH] message_viewport: Rename at_bottom for clarity. --- web/src/message_scroll.js | 2 +- web/src/message_viewport.ts | 9 +++++---- web/src/navigate.js | 2 +- web/src/ui_init.js | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web/src/message_scroll.js b/web/src/message_scroll.js index efa231c7f7..647e7f0cac 100644 --- a/web/src/message_scroll.js +++ b/web/src/message_scroll.js @@ -88,7 +88,7 @@ export function scroll_finished() { }); } - if (message_viewport.at_bottom()) { + if (message_viewport.at_rendered_bottom()) { message_fetch.maybe_load_newer_messages({ msg_list: message_lists.current, }); diff --git a/web/src/message_viewport.ts b/web/src/message_viewport.ts index acd099ea1b..34eba55cdf 100644 --- a/web/src/message_viewport.ts +++ b/web/src/message_viewport.ts @@ -75,7 +75,7 @@ export function message_viewport_info(): MessageViewportInfo { // rendered message feed; messages that are not displayed due to a // limited render window or because they have not been fetched from // the server are not considered. -export function at_bottom(): boolean { +export function at_rendered_bottom(): boolean { const bottom = scrollTop() + height(); const full_height = $scroll_container.prop("scrollHeight"); @@ -86,8 +86,9 @@ export function at_bottom(): boolean { return bottom + 2 >= full_height; } -// This differs from at_bottom in that it only requires the bottom message to -// be visible, but you may be able to scroll down further. +// This differs from at_rendered_bottom in that it only requires the +// bottom message to be visible, but you may be able to scroll down +// further to see the rest of that message. export function bottom_rendered_message_visible(): boolean { const $last_row = rows.last_visible(); if ($last_row.length) { @@ -485,7 +486,7 @@ export function keep_pointer_in_view(): void { } function message_is_far_enough_up(): boolean { - return at_bottom() || $next_row.get_offset_to_window().top <= bottom_threshold; + return at_rendered_bottom() || $next_row.get_offset_to_window().top <= bottom_threshold; } function adjust( diff --git a/web/src/navigate.js b/web/src/navigate.js index e0ee50bb77..7526cc3892 100644 --- a/web/src/navigate.js +++ b/web/src/navigate.js @@ -108,7 +108,7 @@ export function page_up() { } export function page_down() { - if (message_viewport.at_bottom() && !message_lists.current.visibly_empty()) { + if (message_viewport.at_rendered_bottom() && !message_lists.current.visibly_empty()) { message_lists.current.select_id(message_lists.current.last().id, {then_scroll: false}); unread_ops.process_visible(); } else { diff --git a/web/src/ui_init.js b/web/src/ui_init.js index 657a0eeeb8..08b93983b4 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -199,7 +199,7 @@ export function initialize_kitchen_sink_stuff() { if (delta < 0 && message_viewport.at_top()) { navigate.up(); - } else if (delta > 0 && message_viewport.at_bottom()) { + } else if (delta > 0 && message_viewport.at_rendered_bottom()) { navigate.down(); }