Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
unread: Mark all narrow-matching messages as read from banner.
Evy Kassireracc850a3e1a5
diff --git a/web/src/ui_init.js b/web/src/ui_init.jsindex 1f4c5c52a8b..c6aa1c5e523 100644--- a/web/src/ui_init.js+++ b/web/src/ui_init.js@@ -423,7 +423,7 @@ function initialize_unread_ui() {);unread_ui.register_update_unread_counts_hook(inbox_ui.update);- unread_ui.initialize({notify_server_messages_read: unread_ops.notify_server_messages_read});+ unread_ui.initialize({mark_narrow_as_read: unread_ops.mark_narrow_as_read});}export async function initialize_everything(state_data) {diff --git a/web/src/unread_ops.ts b/web/src/unread_ops.tsindex a233f38f49b..caa323ff0b6 100644--- a/web/src/unread_ops.ts+++ b/web/src/unread_ops.ts@@ -827,6 +827,13 @@ export function mark_all_as_read(modal_id?: string): void {bulk_update_read_flags_for_narrow(all_unread_messages_narrow, "add", {}, modal_id);}+export function mark_narrow_as_read(filter: Filter): void {+ bulk_update_read_flags_for_narrow(+ [{operator: "is", operand: "unread", negated: false}, ...filter.terms()],+ "add",+ );+}+export function mark_muted_topic_messages_as_read(modal_id?: string): void {bulk_update_read_flags_for_narrow([diff --git a/web/src/unread_ui.ts b/web/src/unread_ui.tsindex 376416114a8..2df21488d87 100644--- a/web/src/unread_ui.ts+++ b/web/src/unread_ui.ts@@ -5,8 +5,8 @@ import render_mark_as_read_disabled_banner from "../templates/unread_banner/markimport render_mark_as_read_only_in_conversation_view from "../templates/unread_banner/mark_as_read_only_in_conversation_view.hbs";import render_mark_as_read_turned_off_banner from "../templates/unread_banner/mark_as_read_turned_off_banner.hbs";+import type {Filter} from "./filter.ts";import * as message_lists from "./message_lists.ts";-import type {Message} from "./message_store.ts";import * as narrow_state from "./narrow_state.ts";import {web_mark_read_on_scroll_policy_values} from "./settings_config.ts";import * as unread from "./unread.ts";@@ -104,23 +104,19 @@ export function update_unread_counts(skip_animations = false): void {}export function initialize({- notify_server_messages_read,+ mark_narrow_as_read,}: {- notify_server_messages_read: (unread_messages: Message[]) => void;+ mark_narrow_as_read: (filter: Filter) => void;}): void {const skip_animations = true;update_unread_counts(skip_animations);$("body").on("click", "#mark_view_read", () => {assert(message_lists.current !== undefined);- // Mark all messages in the current view as read.- //- // BUG: This logic only supports marking messages visible in- // the present view as read; we need a server API to mark- // every message matching the current search as read.- const unread_messages = message_lists.current- .all_messages()- .filter((message) => message.unread);- notify_server_messages_read(unread_messages);+ // Mark all messages matching the current narrow as read on+ // the server, so that unreads outside the locally fetched+ // range (e.g., older DM conversations in the DM feed) are+ // also marked as read.+ mark_narrow_as_read(message_lists.current.data.filter);// New messages received may be marked as read based on narrow type.message_lists.current.resume_reading();