From 451380b901ce61ab254dc3ea05676fd508e01fa2 Mon Sep 17 00:00:00 2001 From: Brayan Vargas <86427419+b-avb@users.noreply.github.com> Date: Wed, 28 Feb 2024 08:25:34 -0500 Subject: [PATCH] fix(use_listent_message): early return on Reply and None relations (#51) --- src/hooks/use_listen_message.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/hooks/use_listen_message.rs b/src/hooks/use_listen_message.rs index 5c6e0c2..a876189 100644 --- a/src/hooks/use_listen_message.rs +++ b/src/hooks/use_listen_message.rs @@ -138,13 +138,11 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { } None => { if is_in_current_room { - let Some(position) = message_position_local else { + if let Some(position) = message_position_local { + msgs[position] = message.clone() + } else { msgs.push(message.clone()); - - return; - }; - - msgs[position] = message.clone() + } } else { plain_message = Some(message_to_plain_content( &timeline_message.body, @@ -159,13 +157,11 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { } TimelineRelation::Reply(timeline_message) => { if is_in_current_room { - let Some(position) = message_position_local else { + if let Some(position) = message_position_local { + msgs[position] = message.clone(); + } else { msgs.push(message.clone()); - - return; }; - - msgs[position] = message.clone() } else { plain_message = Some(message_to_plain_content( &timeline_message.event.body,