Update published items on the main actor
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -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) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user