From 28250bb2a04802f65cc481d35e2de4f795c33ec3 Mon Sep 17 00:00:00 2001 From: Brayan Vargas <86427419+b-avb@users.noreply.github.com> Date: Fri, 29 Mar 2024 03:43:22 -0500 Subject: [PATCH] fix listen message (#69) --- src/hooks/use_listen_message.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/hooks/use_listen_message.rs b/src/hooks/use_listen_message.rs index 6f7db85..0d5ff08 100644 --- a/src/hooks/use_listen_message.rs +++ b/src/hooks/use_listen_message.rs @@ -43,7 +43,7 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { let message_dispatch_id = use_shared_state::(cx).expect("Unable to use MessageDispatchId"); let threading_to = use_thread(cx); - let position = use_ref(cx, || None); + let position = use_ref::>(cx, || None); let task_sender = use_coroutine(cx, |mut rx: UnboundedReceiver| { to_owned![ @@ -243,6 +243,7 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { while let Some(ev) = rx.next().await { let back_messages = messages.get().clone(); let value = &message_dispatch_id.read().value; + position.set(None); let to_find: Option<(String, Option)> = value.iter().find_map(|(uuid, event_id)| { @@ -255,9 +256,6 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { }) }); - info!("to find {:?}", to_find); - info!("back messages {:?}", back_messages); - if let Some((uuid, _)) = to_find { position.set(back_messages.iter().position(|m| match m { TimelineRelation::None(relation) => relation.event_id == uuid, @@ -292,10 +290,6 @@ pub fn use_listen_message(cx: &ScopeState) -> &UseListenMessagesState { ]; async move { - if let Err(e) = client.sync_once(SyncSettings::default()).await { - log::warn!("{e:?}") - }; - let me = session.get().ok_or(ListenMessageError::SessionNotFound)?; if !*handler_added.read() {