Commit 492aa28e27

492aa28e2787ad314bde149cdca8e9eb0fe2ca1f

parent: f8b5484def

Unsigned

Jakub Panek <me@panekj.dev> · 2025-04-25 18:55 UTC
committer: <poljar@termina.org.uk>

connection: run sync in loop, break on Ok

Client sync exits with Err() in case of any sync issues
and Ok() if it's gracefully shutdown, this fixes a problem
when weechat-matrix-rs stops receiving messages
(most likely due to network connection issue)

Layout: unified · split

src/connection.rs +10 −2
@@ -428,8 +428,9 @@ impl Connection {
428428
429429 let client_ref = &client;
430430
431 let _ret = client
432 .sync_with_callback(sync_settings, |response| async move {
431 loop {
432 let ret = client
433 .sync_with_callback(sync_settings.clone(), |response| async move {
433434 for (room_id, room) in response.rooms.join {
434435 for event in
435436 room.state.iter().filter_map(|e| e.deserialize().ok())
@@ -543,5 +544,12 @@ impl Connection {
543544 LoopCtrl::Continue
544545 })
545546 .await;
547
548 if let Err(err) = ret {
549 error!("Matrix sync failed: {err}");
550 } else {
551 break;
552 }
553 }
546554 }
547555}