aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw-agent/actions.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-07-18 03:58:57 -0400
committerJesse Luehrs <doy@tozt.net>2023-07-18 03:58:57 -0400
commitdeea6de0641d0438dec3b00d4f5948d41c9f3ef3 (patch)
tree114fd1920f81a09518f8e8e9effb6005b3d03105 /src/bin/rbw-agent/actions.rs
parentd2a97be689b034ed056f3ba41a9775635872a073 (diff)
downloadrbw-deea6de0641d0438dec3b00d4f5948d41c9f3ef3.tar.gz
rbw-deea6de0641d0438dec3b00d4f5948d41c9f3ef3.zip
stop trying to reconnect to notifications so aggressively1.8.0
it adds a bunch of latency to every command otherwise
Diffstat (limited to 'src/bin/rbw-agent/actions.rs')
-rw-r--r--src/bin/rbw-agent/actions.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/bin/rbw-agent/actions.rs b/src/bin/rbw-agent/actions.rs
index 6291680..b7295f8 100644
--- a/src/bin/rbw-agent/actions.rs
+++ b/src/bin/rbw-agent/actions.rs
@@ -205,11 +205,10 @@ pub async fn login(
}
}
}
- }
- let err = subscribe_to_notifications(state.clone()).await.err();
- if let Some(e) = err {
- eprintln!("failed to subscribe to notifications: {e}");
+ if let Err(e) = subscribe_to_notifications(state.clone()).await {
+ eprintln!("failed to subscribe to notifications: {e}");
+ }
}
respond_ack(sock).await?;
@@ -685,6 +684,10 @@ async fn config_pinentry() -> anyhow::Result<String> {
pub async fn subscribe_to_notifications(
state: std::sync::Arc<tokio::sync::Mutex<crate::agent::State>>,
) -> anyhow::Result<()> {
+ if state.lock().await.notifications_handler.is_connected() {
+ return Ok(());
+ }
+
// access token might be out of date, so we do a sync to refresh it
sync(None).await?;
@@ -705,11 +708,10 @@ pub async fn subscribe_to_notifications(
.replace("https://", "wss://");
let mut state = state.lock().await;
- let err = state
+ state
.notifications_handler
.connect(websocket_url)
.await
- .err();
-
- err.map_or_else(|| Ok(()), |err| Err(anyhow::anyhow!(err.to_string())))
+ .err()
+ .map_or_else(|| Ok(()), |err| Err(anyhow::anyhow!(err.to_string())))
}