diff --git a/web/src/filter.ts b/web/src/filter.ts index f196975ae0..22d02c51b9 100644 --- a/web/src/filter.ts +++ b/web/src/filter.ts @@ -18,7 +18,6 @@ import type {UserPillItem} from "./search_suggestion"; import {current_user, realm} from "./state_data"; import type {NarrowTerm} from "./state_data"; import * as stream_data from "./stream_data"; -import * as unread from "./unread"; import * as user_topics from "./user_topics"; import * as util from "./util"; @@ -177,7 +176,7 @@ function message_matches_search_term(message: Message, operator: string, operand case "alerted": return message.alerted; case "unread": - return unread.message_unread(message); + return message.unread; case "resolved": return message.type === "stream" && resolved_topic.is_resolved(message.topic); case "followed": diff --git a/web/src/message_list_data.ts b/web/src/message_list_data.ts index c0e7f0fe8a..d0f0220ac3 100644 --- a/web/src/message_list_data.ts +++ b/web/src/message_list_data.ts @@ -6,7 +6,6 @@ import type {Filter} from "./filter"; import type {Message} from "./message_store"; import * as muted_users from "./muted_users"; import {current_user} from "./state_data"; -import * as unread from "./unread"; import * as user_topics from "./user_topics"; import * as util from "./util"; @@ -268,7 +267,7 @@ export class MessageListData { // See https://github.com/zulip/zulip/pull/30008#discussion_r1597279862 for how // ideas on how to possibly improve this. // before `first_unread` calculated below that we haven't fetched yet. - const first_unread = this._items.find((message) => unread.message_unread(message)); + const first_unread = this._items.find((message) => message.unread); if (first_unread) { return first_unread.id; @@ -281,7 +280,7 @@ export class MessageListData { } has_unread_messages(): boolean { - return this._items.some((message) => unread.message_unread(message)); + return this._items.some((message) => message.unread); } add_messages(messages: Message[]): { diff --git a/web/src/message_notifications.js b/web/src/message_notifications.js index bc6b8e49db..3cff30ee68 100644 --- a/web/src/message_notifications.js +++ b/web/src/message_notifications.js @@ -10,7 +10,6 @@ import * as people from "./people"; import * as spoilers from "./spoilers"; import * as stream_data from "./stream_data"; import * as ui_util from "./ui_util"; -import * as unread from "./unread"; import {user_settings} from "./user_settings"; import * as user_topics from "./user_topics"; import * as util from "./util"; @@ -380,7 +379,7 @@ export function received_messages(messages) { if (!message_is_notifiable(message)) { continue; } - if (!unread.message_unread(message)) { + if (!message.unread) { // The message is already read; Zulip is currently in focus. continue; } diff --git a/web/src/unread.ts b/web/src/unread.ts index bc863a1346..9a69f5e82b 100644 --- a/web/src/unread.ts +++ b/web/src/unread.ts @@ -664,13 +664,6 @@ export function clear_and_populate_unread_mention_topics(): void { } } -export function message_unread(message: Message): boolean { - if (message === undefined) { - return false; - } - return message.unread; -} - export function get_read_message_ids(message_ids: number[]): number[] { return message_ids.filter((message_id) => !unread_messages.has(message_id)); } diff --git a/web/src/unread_ui.ts b/web/src/unread_ui.ts index cdb60fb9fe..5aa98d9c56 100644 --- a/web/src/unread_ui.ts +++ b/web/src/unread_ui.ts @@ -143,7 +143,7 @@ export function initialize({ // every message matching the current search as read. const unread_messages = message_lists.current.data .all_messages() - .filter((message) => unread.message_unread(message)); + .filter((message) => message.unread); notify_server_messages_read(unread_messages); // New messages received may be marked as read based on narrow type. message_lists.current.resume_reading(); diff --git a/web/tests/unread.test.js b/web/tests/unread.test.js index beabfb4d1d..9957b79291 100644 --- a/web/tests/unread.test.js +++ b/web/tests/unread.test.js @@ -742,13 +742,6 @@ test("declare_bankruptcy", () => { test_notifiable_count(counts.home_unread_messages, 0); }); -test("message_unread", () => { - // Test some code that might be overly defensive, for line coverage sake. - assert.ok(!unread.message_unread(undefined)); - assert.ok(unread.message_unread({unread: true})); - assert.ok(!unread.message_unread({unread: false})); -}); - test("server_counts", () => { // note that user_id 30 is "me"