message_store: Clarify display_reply_to type for stream/dm messages.

This commit is contained in:
evykassirer 2024-05-11 15:52:58 -07:00 committed by Tim Abbott
parent 724306df10
commit d4d57193df
2 changed files with 2 additions and 4 deletions

View File

@ -120,7 +120,6 @@ export type Message = (
// Added in `message_helper.process_new_message`. // Added in `message_helper.process_new_message`.
sent_by_me: boolean; sent_by_me: boolean;
reply_to: string; reply_to: string;
display_reply_to?: string;
// These properties are used in `message_list_view.js`. // These properties are used in `message_list_view.js`.
starred_status: string; starred_status: string;
@ -139,6 +138,7 @@ export type Message = (
is_stream: false; is_stream: false;
pm_with_url: string; pm_with_url: string;
to_user_ids: string; to_user_ids: string;
display_reply_to: string;
} }
| { | {
type: "stream"; type: "stream";
@ -146,6 +146,7 @@ export type Message = (
is_stream: true; is_stream: true;
stream: string; stream: string;
topic: string; topic: string;
display_reply_to: undefined;
} }
); );

View File

@ -1022,9 +1022,7 @@ function stream_sort(a: Row, b: Row): number {
return sort_comparator(a_stream_name, b_stream_name); return sort_comparator(a_stream_name, b_stream_name);
} }
assert(a_msg.type === "private"); assert(a_msg.type === "private");
assert(a_msg.display_reply_to !== undefined);
assert(b_msg.type === "private"); assert(b_msg.type === "private");
assert(b_msg.display_reply_to !== undefined);
return sort_comparator(a_msg.display_reply_to, b_msg.display_reply_to); return sort_comparator(a_msg.display_reply_to, b_msg.display_reply_to);
} }
// if type is not same sort between "private" and "stream" // if type is not same sort between "private" and "stream"
@ -1035,7 +1033,6 @@ function topic_sort_key(conversation_data: ConversationData): string {
const message = message_store.get(conversation_data.last_msg_id); const message = message_store.get(conversation_data.last_msg_id);
assert(message !== undefined); assert(message !== undefined);
if (message.type === "private") { if (message.type === "private") {
assert(message.display_reply_to !== undefined);
return message.display_reply_to; return message.display_reply_to;
} }
return message.topic; return message.topic;