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 {
428 428
429 let client_ref = &client; 429 let client_ref = &client;
430 430
431 let _ret = client 431 loop {
432 .sync_with_callback(sync_settings, |response| async move { 432 let ret = client
433 .sync_with_callback(sync_settings.clone(), |response| async move {
433 for (room_id, room) in response.rooms.join { 434 for (room_id, room) in response.rooms.join {
434 for event in 435 for event in
435 room.state.iter().filter_map(|e| e.deserialize().ok()) 436 room.state.iter().filter_map(|e| e.deserialize().ok())
@@ -543,5 +544,12 @@ impl Connection {
543 LoopCtrl::Continue 544 LoopCtrl::Continue
544 }) 545 })
545 .await; 546 .await;
547
548 if let Err(err) = ret {
549 error!("Matrix sync failed: {err}");
550 } else {
551 break;
552 }
553 }
546 } 554 }
547} 555}