user_settings: Add option to not mark messages as read on scroll.

These changes introduces an new user option where it allows
users read messages and scroll through their feed without
marking those messages as read.

Fixes: #22804.
This commit is contained in:
Joelute
2023-03-07 20:27:45 -05:00
committed by Tim Abbott
parent ffbe6e870a
commit 938b7917d3
14 changed files with 115 additions and 7 deletions

View File

@@ -7,7 +7,9 @@ import {MessageListView} from "./message_list_view";
import * as narrow_banner from "./narrow_banner";
import * as narrow_state from "./narrow_state";
import {page_params} from "./page_params";
import {web_mark_read_on_scroll_policy_values} from "./settings_config";
import * as stream_data from "./stream_data";
import {user_settings} from "./user_settings";
export class MessageList {
// A MessageList is the main interface for a message feed that is
@@ -173,11 +175,29 @@ export class MessageList {
can_mark_messages_read() {
/* Automatically marking messages as read can be disabled for
two different reasons:
three different reasons:
* The view is structurally a search view, encoded in the
properties of the message_list_data object.
* The user recently marked messages in the view as unread, and
we don't want to lose that state.
* The user has "Mark messages as read on scroll" option
turned on in their user settings.
*/
return (
this.data.can_mark_messages_read() &&
!this.reading_prevented &&
!(
user_settings.web_mark_read_on_scroll_policy ===
web_mark_read_on_scroll_policy_values.never.code
)
);
}
can_mark_messages_read_without_setting() {
/*
Similar to can_mark_messages_read() above, this is a helper
function to check if messages can be automatically read without
the "Do not mark messages as read on scroll" setting.
*/
return this.data.can_mark_messages_read() && !this.reading_prevented;
}