diff --git a/src/chat/gui.rs b/src/chat/gui.rs index 70e59ed..1df8e1e 100644 --- a/src/chat/gui.rs +++ b/src/chat/gui.rs @@ -669,26 +669,24 @@ fn build_ui(ctx: Arc, app: &Application) -> UiModel { #[weak] ctx, move |_| { - if text_entry.text().is_empty() { + let text = text_entry.text().clone(); + + if text.is_empty() { return; } - timeout_add_local_once( - Duration::ZERO, - clone!( - #[weak] - text_entry, - move || { - text_entry.set_text(""); - } - ), - ); - if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) { - if ctx.config(|o| o.debug_logs) { - let msg = format!("Send message error: {}", e.to_string()).to_string(); - add_chat_messages(ctx.clone(), vec![msg]); + text_entry.set_text(""); + + thread::spawn({ + move || { + if let Err(e) = on_send_message(ctx.clone(), &text) { + if ctx.config(|o| o.debug_logs) { + let msg = format!("Send message error: {}", e.to_string()).to_string(); + add_chat_messages(ctx.clone(), vec![msg]); + } + } } - } + }); } )); diff --git a/src/proto/mod.rs b/src/proto/mod.rs index 5c1506e..6811c6f 100644 --- a/src/proto/mod.rs +++ b/src/proto/mod.rs @@ -182,7 +182,7 @@ pub fn connect(host: &str, proxy: Option) -> Result