chore: fix crash on update relays
This commit is contained in:
@@ -188,7 +188,7 @@ impl AppView {
|
|||||||
this.keyboard(false)
|
this.keyboard(false)
|
||||||
.closable(false)
|
.closable(false)
|
||||||
.width(px(420.))
|
.width(px(420.))
|
||||||
.title("Your Messaging Relays is not configured")
|
.title("Your Messaging Relays are not configured")
|
||||||
.child(relays.clone())
|
.child(relays.clone())
|
||||||
.footer(
|
.footer(
|
||||||
div()
|
div()
|
||||||
|
|||||||
@@ -66,41 +66,43 @@ impl Relays {
|
|||||||
|
|
||||||
self.set_loading(true, cx);
|
self.set_loading(true, cx);
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
let client = get_client();
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
|
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let client = get_client();
|
let signer = client.signer().await.expect("Signer is required");
|
||||||
let signer = client.signer().await.unwrap();
|
let public_key = signer
|
||||||
let public_key = signer.get_public_key().await.unwrap();
|
.get_public_key()
|
||||||
|
.await
|
||||||
|
.expect("Cannot get public key");
|
||||||
|
|
||||||
let tags: Vec<Tag> = relays
|
let tags: Vec<Tag> = relays
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|relay| Tag::custom(TagKind::Relay, vec![relay.to_string()]))
|
.map(|relay| Tag::custom(TagKind::Relay, vec![relay.to_string()]))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let event = EventBuilder::new(Kind::InboxRelays, "")
|
let event = EventBuilder::new(Kind::InboxRelays, "")
|
||||||
.tags(tags)
|
.tags(tags)
|
||||||
.build(public_key)
|
.build(public_key)
|
||||||
.sign(&signer)
|
.sign(&signer)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if let Ok(output) = client.send_event(&event).await {
|
|
||||||
_ = tx.send(output.val);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
|
|
||||||
if rx.await.is_ok() {
|
|
||||||
cx.update_window(window_handle, |_, window, cx| {
|
|
||||||
window.close_modal(cx);
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.set_loading(false, cx);
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
if let Ok(output) = client.send_event(&event).await {
|
||||||
|
_ = tx.send(output.val);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
if rx.await.is_ok() {
|
||||||
|
_ = cx.update_window(window_handle, |_, window, cx| {
|
||||||
|
_ = this.update(cx, |this, cx| {
|
||||||
|
this.set_loading(false, cx);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.close_modal(cx);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|||||||
Reference in New Issue
Block a user