wip: refactor

This commit is contained in:
2025-01-02 09:58:42 +07:00
parent d53e75b775
commit 51b392a845
11 changed files with 94 additions and 188 deletions

View File

@@ -10,6 +10,7 @@ use crate::{
pub struct AccountRegistry {
public_key: Option<PublicKey>,
pub(crate) is_loading: bool,
}
impl Global for AccountRegistry {}
@@ -58,6 +59,10 @@ impl AccountRegistry {
.detach();
}
pub fn set_loading(&mut self) {
self.is_loading = false
}
pub fn get(&self) -> Option<PublicKey> {
self.public_key
}
@@ -71,6 +76,9 @@ impl AccountRegistry {
}
fn new() -> Self {
Self { public_key: None }
Self {
public_key: None,
is_loading: true,
}
}
}

View File

@@ -17,10 +17,6 @@ impl MetadataRegistry {
cx.set_global(Self::new());
}
pub fn contains(&self, public_key: PublicKey) -> bool {
self.seens.lock().unwrap().contains(&public_key)
}
pub fn seen(&mut self, public_key: PublicKey, metadata: Option<Metadata>) {
let mut seens = self.seens.lock().unwrap();

View File

@@ -5,14 +5,12 @@ use tokio::sync::mpsc::UnboundedSender;
#[derive(Clone)]
pub enum Signal {
/// Request metadata
ReqMetadata(PublicKey),
/// Receive metadata
RecvMetadata(PublicKey),
/// Receive EOSE
RecvEose(SubscriptionId),
Metadata(PublicKey),
/// Receive event
RecvEvent(Event),
Event(Event),
/// Receive EOSE
Eose,
}
pub struct SignalRegistry {