From 7640717e01a3583f76d1a91c0fef2d4af9e969a7 Mon Sep 17 00:00:00 2001 From: Brayan Vargas <86427419+b-avb@users.noreply.github.com> Date: Wed, 21 Feb 2024 06:01:28 -0500 Subject: [PATCH] Fix/notify new message (#45) * fix: handle notification with new message * chore: minor change --- src/hooks/use_listen_message.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hooks/use_listen_message.rs b/src/hooks/use_listen_message.rs index 06aa419..150e442 100644 --- a/src/hooks/use_listen_message.rs +++ b/src/hooks/use_listen_message.rs @@ -142,18 +142,18 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { let Some(position) = message_position_local else { msgs.push(message.clone()); - plain_message = Some(message_to_plain_content( - &timeline_message.body, - &key_listen_message_image, - &key_listen_message_file, - &key_listen_message_video, - &key_listen_message_html, - )); - return; }; msgs[position] = message.clone() + } else { + plain_message = Some(message_to_plain_content( + &timeline_message.body, + &key_listen_message_image, + &key_listen_message_file, + &key_listen_message_video, + &key_listen_message_html, + )); } } } @@ -162,18 +162,19 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { if is_in_current_room { let Some(position) = message_position_local else { msgs.push(message.clone()); - plain_message = Some(message_to_plain_content( - &timeline_message.event.body, - &key_listen_message_image, - &key_listen_message_file, - &key_listen_message_video, - &key_listen_message_html, - )); return; }; msgs[position] = message.clone() + } else { + plain_message = Some(message_to_plain_content( + &timeline_message.event.body, + &key_listen_message_image, + &key_listen_message_file, + &key_listen_message_video, + &key_listen_message_html, + )); } } TimelineRelation::CustomThread(timeline_message) => { @@ -389,7 +390,6 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { } } } - task_sender.send(( MessageEvent { room,