mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
unread_ops: Add process_scrolled_to_bottom().
There are a few instances where we check if messages can be marked read and mark that list as read when scrolled to bottom. Using this would be nicer and also this function can be extended later to display a banner when messages are not being marked.
This commit is contained in:
@@ -27,9 +27,7 @@ export function down(with_centering) {
|
||||
message_viewport.scrollTop(
|
||||
current_msg_table.safeOuterHeight(true) - message_viewport.height() * 0.1,
|
||||
);
|
||||
if (message_lists.current.can_mark_messages_read()) {
|
||||
unread_ops.mark_current_list_as_read();
|
||||
}
|
||||
unread_ops.process_scrolled_to_bottom();
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -53,9 +51,7 @@ export function to_end() {
|
||||
const next_id = message_lists.current.last().id;
|
||||
message_viewport.set_last_movement_direction(1);
|
||||
message_lists.current.select_id(next_id, {then_scroll: true, from_scroll: true});
|
||||
if (message_lists.current.can_mark_messages_read()) {
|
||||
unread_ops.mark_current_list_as_read();
|
||||
}
|
||||
unread_ops.process_scrolled_to_bottom();
|
||||
}
|
||||
|
||||
function amount_to_paginate() {
|
||||
@@ -115,9 +111,7 @@ export function page_up() {
|
||||
export function page_down() {
|
||||
if (message_viewport.at_bottom() && !message_lists.current.empty()) {
|
||||
message_lists.current.select_id(message_lists.current.last().id, {then_scroll: false});
|
||||
if (message_lists.current.can_mark_messages_read()) {
|
||||
unread_ops.mark_current_list_as_read();
|
||||
}
|
||||
unread_ops.process_scrolled_to_bottom();
|
||||
} else {
|
||||
page_down_the_right_amount();
|
||||
}
|
||||
|
||||
@@ -99,15 +99,17 @@ export function notify_server_message_read(message, options) {
|
||||
notify_server_messages_read([message], options);
|
||||
}
|
||||
|
||||
export function process_scrolled_to_bottom() {
|
||||
if (message_lists.current.can_mark_messages_read()) {
|
||||
mark_current_list_as_read();
|
||||
}
|
||||
}
|
||||
|
||||
// If we ever materially change the algorithm for this function, we
|
||||
// may need to update notifications.received_messages as well.
|
||||
export function process_visible() {
|
||||
if (
|
||||
message_viewport.is_visible_and_focused() &&
|
||||
message_viewport.bottom_message_visible() &&
|
||||
message_lists.current.can_mark_messages_read()
|
||||
) {
|
||||
mark_current_list_as_read();
|
||||
if (message_viewport.is_visible_and_focused() && message_viewport.bottom_message_visible()) {
|
||||
process_scrolled_to_bottom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user