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.

message_view: Don't annoy user with first unread missing logic.

Aman Agrawal60989b3efb6e
diff --git a/web/src/message_view.ts b/web/src/message_view.ts
index 034e3fc068c..68ed994c24c 100644
--- a/web/src/message_view.ts
+++ b/web/src/message_view.ts
@@ -833,6 +833,17 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
first_unread_message_id <
id_info.first_unread_msg_id_pending_server_verification
) {
+ // Do nothing if top of the first unread message is fully on screen
+ // so that we don't annoyingly retarget the user.
+ const $row = msg_list.get_row(first_unread_message_id);
+ if ($row.length > 0) {
+ const row_rect = util.the($row).getBoundingClientRect();
+ const viewport_info = message_viewport.message_viewport_info();
+ if (row_rect.top >= viewport_info.visible_top) {
+ return;
+ }
+ }
+
// We convert the current narrow into a `near` narrow so that
// user doesn't accidentally mark msgs read which they haven't seen.
let terms: NarrowTerm[] = [