git add .
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 2m3s
Rust / build (ubuntu-latest, stable) (pull_request) Failing after 1m36s

This commit is contained in:
2026-01-27 13:38:00 +07:00
parent 4a748ca3d1
commit a39725b1d3
10 changed files with 143 additions and 55 deletions

View File

@@ -72,13 +72,18 @@ impl DeviceRegistry {
subscriptions.push(
// Observe the identity entity
cx.observe(&identity, |this, state, cx| {
if state.read(cx).has_public_key() {
if state.read(cx).relay_list_state() == RelayState::Set {
match state.read(cx).relay_list_state() {
RelayState::Initial => {
this.reset(cx);
}
RelayState::Set => {
this.get_announcement(cx);
if state.read(cx).messaging_relays_state() == RelayState::Set {
this.get_messages(cx);
}
}
if state.read(cx).messaging_relays_state() == RelayState::Set {
this.get_messages(cx);
}
_ => {}
}
}),
);
@@ -193,7 +198,9 @@ impl DeviceRegistry {
let filter = Filter::new()
.kind(Kind::ApplicationSpecificData)
.identifier(IDENTIFIER);
.identifier(IDENTIFIER)
.author(public_key)
.limit(1);
if let Some(event) = client.database().query(filter).await?.first() {
let content = signer.nip44_decrypt(&public_key, &event.content).await?;
@@ -206,6 +213,22 @@ impl DeviceRegistry {
}
}
/// Reset the device state
pub fn reset(&mut self, cx: &mut Context<Self>) {
self.requests.update(cx, |this, cx| {
this.clear();
cx.notify();
});
self.device_signer.update(cx, |this, cx| {
*this = None;
cx.notify();
});
self.state = DeviceState::Initial;
cx.notify();
}
/// Returns the device signer entity
pub fn signer(&self, cx: &App) -> Option<Arc<dyn NostrSigner>> {
self.device_signer.read(cx).clone()
@@ -256,8 +279,8 @@ impl DeviceRegistry {
// Construct a filter to get dekey messages if available
if let Some(signer) = device_signer.as_ref() {
if let Ok(pubkey) = signer.get_public_key().await {
filters.push(Filter::new().kind(Kind::GiftWrap).pubkey(pubkey));
if let Ok(pkey) = signer.get_public_key().await {
filters.push(Filter::new().kind(Kind::GiftWrap).pubkey(pkey));
}
}