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.

narrow: Mark as read when narrowing `by_topic` or `by_recipient`.

Lauryn Menard892c5f48f727
diff --git a/web/src/narrow.js b/web/src/narrow.js
index 164359526ef..dd6cb1e34a9 100644
--- a/web/src/narrow.js
+++ b/web/src/narrow.js
@@ -37,6 +37,7 @@ import * as resize from "./resize";
import * as search from "./search";
import * as search_pill from "./search_pill";
import * as search_pill_widget from "./search_pill_widget";
+import {web_mark_read_on_scroll_policy_values} from "./settings_config";
import * as spectators from "./spectators";
import * as stream_data from "./stream_data";
import * as stream_list from "./stream_list";
@@ -46,6 +47,7 @@ import * as typing_events from "./typing_events";
import * as unread from "./unread";
import * as unread_ops from "./unread_ops";
import * as unread_ui from "./unread_ui";
+import {user_settings} from "./user_settings";
import * as util from "./util";
import * as widgetize from "./widgetize";
@@ -902,6 +904,17 @@ export function by_topic(target_id, opts) {
return;
}
+ if (
+ user_settings.web_mark_read_on_scroll_policy !==
+ web_mark_read_on_scroll_policy_values.never.code
+ ) {
+ // We don't check message_list.can_mark_messages_read
+ // here because the target message_list isn't initialized;
+ // but the targeted message is about to be marked read
+ // in the new view.
+ unread_ops.notify_server_message_read(original);
+ }
+
const search_terms = [
{operator: "stream", operand: original.stream},
{operator: "topic", operand: original.topic},
@@ -910,12 +923,22 @@ export function by_topic(target_id, opts) {
activate(search_terms, opts);
}
-// Called for the 'narrow by stream' hotkey.
export function by_recipient(target_id, opts) {
opts = {then_select_id: target_id, ...opts};
// don't use message_lists.current as it won't work for muted messages or for out-of-narrow links
const message = message_store.get(target_id);
+ if (
+ user_settings.web_mark_read_on_scroll_policy !==
+ web_mark_read_on_scroll_policy_values.never.code
+ ) {
+ // We don't check message_list.can_mark_messages_read
+ // here because the target message_list isn't initialized;
+ // but the targeted message is about to be marked read
+ // in the new view.
+ unread_ops.notify_server_message_read(message);
+ }
+
switch (message.type) {
case "private":
by("dm", message.reply_to, opts);