.
This commit is contained in:
@@ -111,18 +111,10 @@ impl DeviceRegistry {
|
||||
/// Create a new device registry instance
|
||||
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
|
||||
// Get announcement when signer is set
|
||||
let subscription = cx.subscribe_in(&nostr, window, |this, _e, event, _window, cx| {
|
||||
match event {
|
||||
StateEvent::SignerSet => {
|
||||
this.set_subscribing(false, cx);
|
||||
this.set_requesting(false, cx);
|
||||
}
|
||||
StateEvent::RelayConnected => {
|
||||
this.get_announcement(cx);
|
||||
}
|
||||
_ => {}
|
||||
if event == &StateEvent::SignerSet {
|
||||
this.set_subscribing(false, cx);
|
||||
this.set_requesting(false, cx);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -147,6 +139,7 @@ impl DeviceRegistry {
|
||||
self.tasks.push(cx.background_spawn(async move {
|
||||
let mut notifications = client.notifications();
|
||||
let mut processed_events = HashSet::new();
|
||||
let mut found_relay_list = false;
|
||||
|
||||
while let Some(notification) = notifications.next().await {
|
||||
if let ClientNotification::Message { message, .. } = notification
|
||||
@@ -158,6 +151,17 @@ impl DeviceRegistry {
|
||||
}
|
||||
|
||||
match event.kind {
|
||||
Kind::RelayList => {
|
||||
// Skip if the relay list has already been found
|
||||
if found_relay_list {
|
||||
continue;
|
||||
}
|
||||
// Verify the relay list event is signed by the user's signer
|
||||
if verify_author(&client, event.as_ref()).await {
|
||||
tx.send_async(event.into_owned()).await?;
|
||||
found_relay_list = true;
|
||||
}
|
||||
}
|
||||
Kind::Custom(4454) => {
|
||||
if verify_author(&client, event.as_ref()).await {
|
||||
tx.send_async(event.into_owned()).await?;
|
||||
|
||||
Reference in New Issue
Block a user