message edit: Select message id before getting row.

Getting the row was sometimes causing errors because
the row wasn't in the DOM at the time of trying to
get it. By selecting the message id first, we ensure
it's in the DOM before we call `get_row`.

More conversation here:
https://chat.zulip.org/#narrow/stream/464-kandra-js-errors/topic/Error.3A.20Caller.20should.20pass.20in.20a.20single.20row.2E
This commit is contained in:
evykassirer
2024-01-04 12:00:22 -08:00
committed by Anders Kaseorg
parent 2a57aa6cea
commit 17bc9af106

View File

@@ -1132,6 +1132,8 @@ export function edit_last_sent_message() {
return;
}
message_lists.current.select_id(msg.id, {then_scroll: true, from_scroll: true});
const $msg_row = message_lists.current.get_row(msg.id);
if (!$msg_row) {
// This should never happen, since we got the message above
@@ -1140,8 +1142,6 @@ export function edit_last_sent_message() {
return;
}
message_lists.current.select_id(msg.id, {then_scroll: true, from_scroll: true});
// Finally do the real work!
compose_actions.cancel();
start($msg_row, () => {