This commit is contained in:
2026-06-10 13:00:51 +07:00
parent 0230fcff23
commit e812ae05a9
8 changed files with 94 additions and 67 deletions

View File

@@ -360,7 +360,6 @@ impl ChatRegistry {
// Subscribe
client
.subscribe(vec![msg_relays, contact_list])
.with_id(SubscriptionId::new("user-meta"))
.close_on(opts)
.await?;
@@ -622,7 +621,13 @@ impl ChatRegistry {
/// Load all rooms from the database.
pub fn get_rooms(&mut self, cx: &mut Context<Self>) {
let task = self.get_rooms_from_database(cx);
let nostr = NostrRegistry::global(cx);
let Some(public_key) = nostr.read(cx).signer_pubkey(cx) else {
return;
};
let task = self.get_rooms_from_database(public_key, cx);
self.tasks.push(cx.spawn(async move |this, cx| {
match task.await {
@@ -642,14 +647,14 @@ impl ChatRegistry {
}
/// Create a task to load rooms from the database
fn get_rooms_from_database(&self, cx: &App) -> Task<Result<HashSet<Room>, Error>> {
fn get_rooms_from_database(
&self,
public_key: PublicKey,
cx: &App,
) -> Task<Result<HashSet<Room>, Error>> {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(public_key) = nostr.read(cx).signer_pubkey(cx) else {
return Task::ready(Err(anyhow!("Signer is required")));
};
cx.background_spawn(async move {
// Get contacts
let contacts = client