mirror of https://github.com/zulip/zulip.git
recent_view_ui: Fix dm rows not updated for deleted messages.
Tested by deleting a DM and navigating to recent view. No error is thrown and dm row is correctly placed. Co-authored-by: Tim Abbott <tabbott@zulip.com>
This commit is contained in:
parent
1ccf5e3ac3
commit
dd7a5ac4c5
|
@ -94,6 +94,12 @@ export function get_messages_in_topic(stream_id: number, topic: string): Message
|
|||
);
|
||||
}
|
||||
|
||||
export function get_messages_in_dm_conversations(user_ids_strings: Set<string>): Message[] {
|
||||
return all_messages_data
|
||||
.all_messages()
|
||||
.filter((x) => x.type === "private" && user_ids_strings.has(x.to_user_ids));
|
||||
}
|
||||
|
||||
export function get_max_message_id_in_stream(stream_id: number): number {
|
||||
let max_message_id = 0;
|
||||
for (const msg of all_messages_data.all_messages()) {
|
||||
|
|
|
@ -794,6 +794,31 @@ export function update_topics_of_deleted_message_ids(message_ids: number[]): voi
|
|||
msgs_to_process.push(...msgs);
|
||||
}
|
||||
|
||||
const dm_conversations_to_rerender = new Set<string>();
|
||||
for (const msg_id of message_ids) {
|
||||
const msg = message_store.get(msg_id);
|
||||
if (msg === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.type === "private") {
|
||||
const key = recent_view_util.get_key_from_message(msg);
|
||||
// Important to assert since we use the key in get_messages_in_dm_conversation.
|
||||
assert(key === msg.to_user_ids);
|
||||
dm_conversations_to_rerender.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of dm_conversations_to_rerender) {
|
||||
recent_view_data.conversations.delete(key);
|
||||
}
|
||||
if (dm_conversations_to_rerender.size > 0) {
|
||||
const dm_messages_to_process = message_util.get_messages_in_dm_conversations(
|
||||
dm_conversations_to_rerender,
|
||||
);
|
||||
msgs_to_process.push(...dm_messages_to_process);
|
||||
}
|
||||
|
||||
if (msgs_to_process.length > 0) {
|
||||
process_messages(msgs_to_process);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue