feat: add si cli
This commit is contained in:
@@ -41,6 +41,8 @@ pub enum BackendEvent {
|
||||
status: PushStepStatus,
|
||||
},
|
||||
Error(String),
|
||||
/// The relay list, profile and grasp list of a new identity were published; `Err` when no relay took them.
|
||||
IdentityPublished(Result<(), String>),
|
||||
}
|
||||
|
||||
impl BackendEvent {
|
||||
@@ -550,13 +552,19 @@ impl Backend {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
if let Err(error) = futures::future::try_join_all(publishes).await {
|
||||
this.update(cx, |_this, cx| {
|
||||
cx.emit(BackendEvent::error(format!(
|
||||
"identity created, but publishing it failed: {error}"
|
||||
)));
|
||||
})?;
|
||||
}
|
||||
let published = futures::future::try_join_all(publishes)
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(|error| {
|
||||
format!("identity created, but publishing it failed: {error}")
|
||||
});
|
||||
|
||||
this.update(cx, |_this, cx| {
|
||||
if let Err(message) = &published {
|
||||
cx.emit(BackendEvent::error(message.clone()));
|
||||
}
|
||||
cx.emit(BackendEvent::IdentityPublished(published));
|
||||
})?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})
|
||||
@@ -1153,7 +1161,7 @@ impl Backend {
|
||||
self.passphrase_required
|
||||
}
|
||||
|
||||
pub fn sign_out(&mut self, cx: &mut Context<Self>) {
|
||||
pub fn sign_out(&mut self, cx: &mut Context<Self>) -> Task<Result<(), Error>> {
|
||||
self.supersede_session();
|
||||
// Nothing may be signed with the identity the user just left.
|
||||
self.signer.swap_inner(Keys::generate());
|
||||
@@ -1165,6 +1173,11 @@ impl Backend {
|
||||
});
|
||||
|
||||
let delete = cx.delete_credentials(USER_KEYRING);
|
||||
|
||||
cx.emit(BackendEvent::SignerChanged);
|
||||
cx.emit(BackendEvent::SignerRequired);
|
||||
cx.notify();
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
if let Err(error) = delete.await {
|
||||
this.update(cx, |_this, cx| {
|
||||
@@ -1176,10 +1189,6 @@ impl Backend {
|
||||
|
||||
Ok::<(), Error>(())
|
||||
})
|
||||
.detach();
|
||||
cx.emit(BackendEvent::SignerChanged);
|
||||
cx.emit(BackendEvent::SignerRequired);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn sync_inbox(&mut self, cx: &mut Context<Self>) {
|
||||
|
||||
Reference in New Issue
Block a user