unread: Remove useless message_unread function.

This commit is contained in:
evykassirer 2024-09-27 15:46:01 -07:00 committed by Tim Abbott
parent 4215c9d707
commit 6c390551de
6 changed files with 5 additions and 22 deletions

View File

@ -18,7 +18,6 @@ import type {UserPillItem} from "./search_suggestion";
import {current_user, realm} from "./state_data"; import {current_user, realm} from "./state_data";
import type {NarrowTerm} from "./state_data"; import type {NarrowTerm} from "./state_data";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as unread from "./unread";
import * as user_topics from "./user_topics"; import * as user_topics from "./user_topics";
import * as util from "./util"; import * as util from "./util";
@ -177,7 +176,7 @@ function message_matches_search_term(message: Message, operator: string, operand
case "alerted": case "alerted":
return message.alerted; return message.alerted;
case "unread": case "unread":
return unread.message_unread(message); return message.unread;
case "resolved": case "resolved":
return message.type === "stream" && resolved_topic.is_resolved(message.topic); return message.type === "stream" && resolved_topic.is_resolved(message.topic);
case "followed": case "followed":

View File

@ -6,7 +6,6 @@ import type {Filter} from "./filter";
import type {Message} from "./message_store"; import type {Message} from "./message_store";
import * as muted_users from "./muted_users"; import * as muted_users from "./muted_users";
import {current_user} from "./state_data"; import {current_user} from "./state_data";
import * as unread from "./unread";
import * as user_topics from "./user_topics"; import * as user_topics from "./user_topics";
import * as util from "./util"; import * as util from "./util";
@ -268,7 +267,7 @@ export class MessageListData {
// See https://github.com/zulip/zulip/pull/30008#discussion_r1597279862 for how // See https://github.com/zulip/zulip/pull/30008#discussion_r1597279862 for how
// ideas on how to possibly improve this. // ideas on how to possibly improve this.
// before `first_unread` calculated below that we haven't fetched yet. // 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) { if (first_unread) {
return first_unread.id; return first_unread.id;
@ -281,7 +280,7 @@ export class MessageListData {
} }
has_unread_messages(): boolean { has_unread_messages(): boolean {
return this._items.some((message) => unread.message_unread(message)); return this._items.some((message) => message.unread);
} }
add_messages(messages: Message[]): { add_messages(messages: Message[]): {

View File

@ -10,7 +10,6 @@ import * as people from "./people";
import * as spoilers from "./spoilers"; import * as spoilers from "./spoilers";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as ui_util from "./ui_util"; import * as ui_util from "./ui_util";
import * as unread from "./unread";
import {user_settings} from "./user_settings"; import {user_settings} from "./user_settings";
import * as user_topics from "./user_topics"; import * as user_topics from "./user_topics";
import * as util from "./util"; import * as util from "./util";
@ -380,7 +379,7 @@ export function received_messages(messages) {
if (!message_is_notifiable(message)) { if (!message_is_notifiable(message)) {
continue; continue;
} }
if (!unread.message_unread(message)) { if (!message.unread) {
// The message is already read; Zulip is currently in focus. // The message is already read; Zulip is currently in focus.
continue; continue;
} }

View File

@ -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[] { export function get_read_message_ids(message_ids: number[]): number[] {
return message_ids.filter((message_id) => !unread_messages.has(message_id)); return message_ids.filter((message_id) => !unread_messages.has(message_id));
} }

View File

@ -143,7 +143,7 @@ export function initialize({
// every message matching the current search as read. // every message matching the current search as read.
const unread_messages = message_lists.current.data const unread_messages = message_lists.current.data
.all_messages() .all_messages()
.filter((message) => unread.message_unread(message)); .filter((message) => message.unread);
notify_server_messages_read(unread_messages); notify_server_messages_read(unread_messages);
// New messages received may be marked as read based on narrow type. // New messages received may be marked as read based on narrow type.
message_lists.current.resume_reading(); message_lists.current.resume_reading();

View File

@ -742,13 +742,6 @@ test("declare_bankruptcy", () => {
test_notifiable_count(counts.home_unread_messages, 0); 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", () => { test("server_counts", () => {
// note that user_id 30 is "me" // note that user_id 30 is "me"