aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw-agent/agent.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-07-18 23:12:34 -0400
committerJesse Luehrs <doy@tozt.net>2023-07-18 23:12:34 -0400
commit7a0eae68c1f3496a1d421b61f66115a7889d7e92 (patch)
treed8c1bf89e3a5ba014241e622a0a506ab85dd199f /src/bin/rbw-agent/agent.rs
parentc641445f05d107c6317c99123046cef6b47f22c7 (diff)
downloadrbw-7a0eae68c1f3496a1d421b61f66115a7889d7e92.tar.gz
rbw-7a0eae68c1f3496a1d421b61f66115a7889d7e92.zip
reconnect to websockets after every successful sync
rather than scattering it around various parts of the code
Diffstat (limited to 'src/bin/rbw-agent/agent.rs')
-rw-r--r--src/bin/rbw-agent/agent.rs25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/bin/rbw-agent/agent.rs b/src/bin/rbw-agent/agent.rs
index 131bab2..29e400b 100644
--- a/src/bin/rbw-agent/agent.rs
+++ b/src/bin/rbw-agent/agent.rs
@@ -89,13 +89,6 @@ impl Agent {
Sync(()),
}
- let err =
- crate::actions::subscribe_to_notifications(self.state.clone())
- .await;
- if let Err(e) = err {
- eprintln!("failed to subscribe to notifications: {e:#}");
- }
-
let c: tokio::sync::mpsc::UnboundedReceiver<
notifications::NotificationMessage,
> = {
@@ -160,18 +153,10 @@ impl Agent {
tokio::spawn(async move {
// this could fail if we aren't logged in, but we
// don't care about that
- match crate::actions::sync(None).await {
- Ok(()) => {
- if let Err(e) = crate::actions::subscribe_to_notifications(
- state,
- )
- .await {
- eprintln!("failed to subscribe to notifications: {e:#}");
- }
- }
- Err(e) => {
- eprintln!("failed to sync: {e:#}");
- }
+ if let Err(e) =
+ crate::actions::sync(None, state.clone()).await
+ {
+ eprintln!("failed to sync: {e:#}");
}
});
self.state.lock().await.set_sync_timeout();
@@ -223,7 +208,7 @@ async fn handle_request(
false
}
rbw::protocol::Action::Sync => {
- crate::actions::sync(Some(sock)).await?;
+ crate::actions::sync(Some(sock), state.clone()).await?;
false
}
rbw::protocol::Action::Decrypt {