add relay states to ui
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 1m33s
Rust / build (ubuntu-latest, stable) (pull_request) Failing after 1m31s

This commit is contained in:
2026-02-11 17:46:10 +07:00
parent 9380288fc1
commit 836d9a99e1
10 changed files with 102 additions and 26 deletions

View File

@@ -12,13 +12,11 @@ use nostr_lmdb::NostrLmdb;
use nostr_sdk::prelude::*;
mod constants;
mod device;
mod event;
mod nip05;
mod signer;
pub use constants::*;
pub use device::*;
pub use event::*;
pub use nip05::*;
pub use signer::*;
@@ -154,13 +152,13 @@ impl NostrRegistry {
let client = self.client();
self.tasks.push(cx.background_spawn(async move {
// Add bootstrap relay to the relay pool
for url in BOOTSTRAP_RELAYS.into_iter() {
// Add search relay to the relay pool
for url in SEARCH_RELAYS.into_iter() {
client.add_relay(url).await?;
}
// Add search relay to the relay pool
for url in SEARCH_RELAYS.into_iter() {
// Add bootstrap relay to the relay pool
for url in BOOTSTRAP_RELAYS.into_iter() {
client.add_relay(url).await?;
}
@@ -404,6 +402,12 @@ impl NostrRegistry {
let client = self.client();
let nip65 = self.nip65.downgrade();
// Set state to checking
self.nip65.update(cx, |this, cx| {
*this = RelayState::Checking;
cx.notify();
});
let task: Task<Result<RelayState, Error>> = cx.background_spawn(async move {
let signer = client.signer().context("Signer not found")?;
let public_key = signer.get_public_key().await?;
@@ -479,6 +483,12 @@ impl NostrRegistry {
let client = self.client();
let nip17 = self.nip17.downgrade();
// Set state to checking
self.nip17.update(cx, |this, cx| {
*this = RelayState::Checking;
cx.notify();
});
let task: Task<Result<RelayState, Error>> = cx.background_spawn(async move {
let signer = client.signer().context("Signer not found")?;
let public_key = signer.get_public_key().await?;
@@ -966,6 +976,10 @@ impl RelayState {
matches!(self, RelayState::Idle)
}
pub fn checking(&self) -> bool {
matches!(self, RelayState::Checking)
}
pub fn not_configured(&self) -> bool {
matches!(self, RelayState::NotConfigured)
}