echo: Update cached message data for locally echoed messages.

Since we only pass non echo messages to
message_events.insert_new_messages, where message lists get
updated, it is important to update locally echoed messages here.
This commit is contained in:
Aman Agrawal 2024-11-01 16:10:46 +05:30 committed by Tim Abbott
parent 96b62a5372
commit 06a50eaa78
1 changed files with 11 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import * as echo_state from "./echo_state";
import * as local_message from "./local_message";
import * as markdown from "./markdown";
import * as message_events_util from "./message_events_util";
import * as message_list_data_cache from "./message_list_data_cache";
import * as message_lists from "./message_lists";
import * as message_live_update from "./message_live_update";
import * as message_store from "./message_store";
@ -560,6 +561,16 @@ export function process_from_server(messages: ServerMessage[]): ServerMessage[]
msg_list.add_messages(msgs_to_rerender_or_add_to_narrow, {});
}
}
for (const msg_list_data of message_lists.non_rendered_data()) {
if (!msg_list_data.filter.can_apply_locally()) {
// Ideally we would ask server to if messages matches filter
// but it is not worth doing so for every new message.
message_list_data_cache.remove(msg_list_data.filter);
} else {
msg_list_data.add_messages(msgs_to_rerender_or_add_to_narrow);
}
}
}
return non_echo_messages;