Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unread_ops: Add process_scrolled_to_bottom().

Dinesha2ca558c3ef5
diff --git a/static/js/navigate.js b/static/js/navigate.js
index 527f5585435..71fe2e2f1e6 100644
--- a/static/js/navigate.js
+++ b/static/js/navigate.js
@@ -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();
}
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index 84aa686f1b3..34fb634e63a 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -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();
}
}