reify_message_id: Save id on most up-to-date message object.

Previously we relied on `echo.reify_message_id` to set the new
`id` and `locally_echoed` value, but it was setting this on
the message stored in `waiting_for_id`, which isn't guaranteed
to be the same as the message in the message store. Once
`process_new_message` stops mutating the message it gets and
returns a new message object, this would have caused a bug.
This commit is contained in:
evykassirer 2024-05-28 17:58:29 -07:00 committed by Tim Abbott
parent bab1dc5d9c
commit 59a743de01
1 changed files with 2 additions and 0 deletions

View File

@ -275,6 +275,8 @@ export function update_status_emoji_info(
export function reify_message_id({old_id, new_id}: {old_id: number; new_id: number}): void { export function reify_message_id({old_id, new_id}: {old_id: number; new_id: number}): void {
const message = stored_messages.get(old_id); const message = stored_messages.get(old_id);
if (message !== undefined) { if (message !== undefined) {
message.id = new_id;
message.locally_echoed = false;
stored_messages.set(new_id, message); stored_messages.set(new_id, message);
stored_messages.delete(old_id); stored_messages.delete(old_id);
} }