message_viewport: Rename bottom_message_visible.

This commit is contained in:
Tim Abbott
2024-01-31 13:38:10 -08:00
parent 6562ea94e4
commit 45f9bd21e5
4 changed files with 8 additions and 5 deletions

View File

@@ -14,7 +14,10 @@ import * as unread_ui from "./unread_ui";
let hide_scroll_to_bottom_timer; let hide_scroll_to_bottom_timer;
export function hide_scroll_to_bottom() { export function hide_scroll_to_bottom() {
const $show_scroll_to_bottom_button = $("#scroll-to-bottom-button-container"); const $show_scroll_to_bottom_button = $("#scroll-to-bottom-button-container");
if (message_viewport.bottom_message_visible() || message_lists.current.visibly_empty()) { if (
message_viewport.bottom_rendered_message_visible() ||
message_lists.current.visibly_empty()
) {
// If last message is visible, just hide the // If last message is visible, just hide the
// scroll to bottom button. // scroll to bottom button.
$show_scroll_to_bottom_button.removeClass("show"); $show_scroll_to_bottom_button.removeClass("show");
@@ -34,7 +37,7 @@ export function hide_scroll_to_bottom() {
} }
export function show_scroll_to_bottom_button() { export function show_scroll_to_bottom_button() {
if (message_viewport.bottom_message_visible()) { if (message_viewport.bottom_rendered_message_visible()) {
// Only show scroll to bottom button when // Only show scroll to bottom button when
// last message is not visible in the // last message is not visible in the
// current scroll position. // current scroll position.

View File

@@ -88,7 +88,7 @@ export function at_bottom(): boolean {
// This differs from at_bottom in that it only requires the bottom message to // 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. // be visible, but you may be able to scroll down further.
export function bottom_message_visible(): boolean { export function bottom_rendered_message_visible(): boolean {
const $last_row = rows.last_visible(); const $last_row = rows.last_visible();
if ($last_row.length) { if ($last_row.length) {
const message_bottom = $last_row[0].getBoundingClientRect().bottom; const message_bottom = $last_row[0].getBoundingClientRect().bottom;

View File

@@ -459,7 +459,7 @@ function process_scrolled_to_bottom() {
export function process_visible() { export function process_visible() {
if ( if (
viewport_is_visible_and_focused() && viewport_is_visible_and_focused() &&
message_viewport.bottom_message_visible() && message_viewport.bottom_rendered_message_visible() &&
message_lists.current.view.is_end_rendered() message_lists.current.view.is_end_rendered()
) { ) {
process_scrolled_to_bottom(); process_scrolled_to_bottom();

View File

@@ -100,7 +100,7 @@ run_test("unread_ops", ({override}) => {
$("#message_feed_container").show(); $("#message_feed_container").show();
// Make our "test" message appear visible. // Make our "test" message appear visible.
override(message_viewport, "bottom_message_visible", () => true); override(message_viewport, "bottom_rendered_message_visible", () => true);
// Set message_lists.current containing messages that can be marked read // Set message_lists.current containing messages that can be marked read
override(message_lists.current, "all_messages", () => test_messages); override(message_lists.current, "all_messages", () => test_messages);