Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
echo: Start tracking local messages before updating sidebars.
roanster007da75fed5be56
diff --git a/web/src/echo.ts b/web/src/echo.tsindex 95e95b05216..2841862575e 100644--- a/web/src/echo.ts+++ b/web/src/echo.ts@@ -237,6 +237,12 @@ export function build_display_recipient(message: LocalMessage): DisplayRecipientreturn display_recipient;}+export function track_local_message(message: Message): void {+ assert(message.local_id !== undefined);+ echo_state.set_message_waiting_for_id(message.local_id, message);+ echo_state.set_message_waiting_for_ack(message.local_id, message);+}+export function insert_local_message(message_request: MessageRequest,local_id_float: number,@@ -273,9 +279,6 @@ export function insert_local_message(const [message] = insert_new_messages([local_message], true, true);assert(message !== undefined);- assert(message.local_id !== undefined);- echo_state.set_message_waiting_for_id(message.local_id, message);- echo_state.set_message_waiting_for_ack(message.local_id, message);return message;}diff --git a/web/src/message_events.js b/web/src/message_events.jsindex 0a7643c53df..02a1240fdcd 100644--- a/web/src/message_events.js+++ b/web/src/message_events.js@@ -11,6 +11,7 @@ import * as compose_state from "./compose_state";import * as compose_validate from "./compose_validate";import * as direct_message_group_data from "./direct_message_group_data";import * as drafts from "./drafts";+import * as echo from "./echo";import * as message_edit from "./message_edit";import * as message_edit_history from "./message_edit_history";import * as message_events_util from "./message_events_util";@@ -239,6 +240,13 @@ export function insert_new_messages(messages, sent_by_this_client, deliver_localunread_ui.update_unread_counts();}+ // Messages being locally echoed need must be inserted into this+ // tracking before we update the stream sidebar, to take advantage+ // of how stream_topic_history uses the echo data structures.+ if (deliver_locally) {+ messages.map((message) => echo.track_local_message(message));+ }+unread_ops.process_visible();message_notifications.received_messages(messages);stream_list.update_streams_sidebar();diff --git a/web/tests/echo.test.js b/web/tests/echo.test.jsindex 685d9c81ced..39555fd1d3c 100644--- a/web/tests/echo.test.js+++ b/web/tests/echo.test.js@@ -372,7 +372,10 @@ run_test("test reify_message_id", ({override}) => {sender_id: 123,draft_id: 100,};- echo.insert_local_message(message_request, local_id_float, (messages) => messages);+ echo.insert_local_message(message_request, local_id_float, (messages) => {+ messages.map((message) => echo.track_local_message(message));+ return messages;+ });let message_store_reify_called = false;let notifications_reify_called = false;