Update published items on the main actor

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-08-27 10:18:03 -07:00
parent 940b83f5c4
commit 76b6d5c545
2 changed files with 9 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ class FollowersModel: ObservableObject {
self.profilesListener = nil
}
@MainActor
func handle_contact_event(_ ev: NostrEvent) {
if has_contact.contains(ev.pubkey) {
return
@@ -93,7 +94,7 @@ class FollowersModel: ObservableObject {
func handle_event(ev: NostrEvent) {
if ev.known_kind == .contacts {
handle_contact_event(ev)
Task { await handle_contact_event(ev) }
}
}
}

View File

@@ -87,7 +87,7 @@ class ProfileModel: ObservableObject, Equatable {
}
guard let txn = NdbTxn(ndb: damus.ndb) else { return }
load_profiles(context: "profile", load: .from_events(events.events), damus_state: damus, txn: txn)
progress += 1
await bumpUpProgress()
}
profileListener?.cancel()
profileListener = Task {
@@ -102,7 +102,7 @@ class ProfileModel: ObservableObject, Equatable {
case .eose: break
}
}
progress += 1
await bumpUpProgress()
}
conversationListener?.cancel()
conversationListener = Task {
@@ -110,6 +110,11 @@ class ProfileModel: ObservableObject, Equatable {
}
}
@MainActor
func bumpUpProgress() {
progress += 1
}
func listenToConversations() async {
// Only subscribe to conversation events if the profile is not us.
guard pubkey != damus.pubkey else {