fix: fixes for transport JsonRPC (#6680)

Follow-up to #6582

---------

Co-authored-by: adbenitez <asieldbenitez@gmail.com>
This commit is contained in:
Hocuri
2025-03-25 17:47:27 +01:00
committed by GitHub
parent e951a697ec
commit 0df86b6308
7 changed files with 186 additions and 130 deletions

View File

@@ -144,7 +144,8 @@ impl Context {
// We are using Anyhow's .context() and to show the
// inner error, too, we need the {:#}:
let error_msg = stock_str::configuration_failed(self, &format!("{err:#}")).await;
progress!(self, 0, Some(error_msg));
progress!(self, 0, Some(error_msg.clone()));
bail!(error_msg);
} else {
param.save(self).await?;
progress!(self, 1000);
@@ -157,9 +158,22 @@ impl Context {
/// using the server encoded in the QR code.
/// See [Self::add_transport].
pub async fn add_transport_from_qr(&self, qr: &str) -> Result<()> {
set_account_from_qr(self, qr).await?;
self.configure().await?;
self.stop_io().await;
let result = async move {
set_account_from_qr(self, qr).await?;
self.configure().await?;
Ok(())
}
.await;
if result.is_err() {
if let Ok(true) = self.is_configured().await {
self.start_io().await;
}
return result;
}
self.start_io().await;
Ok(())
}