activity: Don't read new messages without user activity.

We have a bug where we can mark messages as read as a result of a
desktop left open with the Zulip window focused. To avoid it,
we only mark new messages as read if there is some user activity.

Note that we scroll to bring new messages into view which can
mark them as read.
This commit is contained in:
Aman Agrawal
2024-10-20 18:50:53 +00:00
committed by Tim Abbott
parent 72caf5641e
commit 32030a7548
6 changed files with 46 additions and 5 deletions

View File

@@ -634,6 +634,16 @@ export function initialize_everything(state_data) {
initialize_unread_ui();
activity.initialize();
activity.register_on_new_user_input_hook(() => {
// Instead of marking new messages as read immediately when bottom
// of feed is visible, we wait for user input to mark them as read.
// This is to prevent marking messages as read unintentionally,
// especially when user is away from screen and the window is focused.
if (activity.received_new_messages && activity.new_user_input) {
unread_ops.process_visible();
activity.set_received_new_messages(false);
}
});
activity_ui.initialize({
narrow_by_email(email) {
message_view.show(