ensure relay connection
This commit is contained in:
@@ -73,14 +73,19 @@ impl DeviceRegistry {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
let state = DeviceState::default();
|
||||
|
||||
let subscription =
|
||||
Some(
|
||||
cx.subscribe_in(&nostr, window, |this, _state, ev, _window, cx| {
|
||||
if let StateEvent::SignerSet = ev {
|
||||
this.get_announcement(cx);
|
||||
}
|
||||
}),
|
||||
);
|
||||
let subscription = Some(cx.subscribe_in(
|
||||
&nostr,
|
||||
window,
|
||||
|this, _state, event, _window, cx| match event {
|
||||
StateEvent::SignerSet => {
|
||||
this.reset(cx);
|
||||
}
|
||||
StateEvent::RelayConnected => {
|
||||
this.get_announcement(cx);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
));
|
||||
|
||||
cx.defer_in(window, |this, window, cx| {
|
||||
this.handle_notifications(window, cx);
|
||||
@@ -269,9 +274,6 @@ impl DeviceRegistry {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
let client = nostr.read(cx).client();
|
||||
|
||||
// Reset state before fetching announcement
|
||||
self.reset(cx);
|
||||
|
||||
let task: Task<Result<Event, Error>> = cx.background_spawn(async move {
|
||||
let signer = client.signer().context("Signer not found")?;
|
||||
let public_key = signer.get_public_key().await?;
|
||||
@@ -373,7 +375,6 @@ impl DeviceRegistry {
|
||||
if keys.public_key() != device_pubkey {
|
||||
return Err(anyhow!("Key mismatch"));
|
||||
};
|
||||
|
||||
Ok(keys)
|
||||
} else {
|
||||
Err(anyhow!("Key not found"))
|
||||
|
||||
Reference in New Issue
Block a user