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
|
self.profilesListener = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
func handle_contact_event(_ ev: NostrEvent) {
|
func handle_contact_event(_ ev: NostrEvent) {
|
||||||
if has_contact.contains(ev.pubkey) {
|
if has_contact.contains(ev.pubkey) {
|
||||||
return
|
return
|
||||||
@@ -93,7 +94,7 @@ class FollowersModel: ObservableObject {
|
|||||||
|
|
||||||
func handle_event(ev: NostrEvent) {
|
func handle_event(ev: NostrEvent) {
|
||||||
if ev.known_kind == .contacts {
|
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 }
|
guard let txn = NdbTxn(ndb: damus.ndb) else { return }
|
||||||
load_profiles(context: "profile", load: .from_events(events.events), damus_state: damus, txn: txn)
|
load_profiles(context: "profile", load: .from_events(events.events), damus_state: damus, txn: txn)
|
||||||
progress += 1
|
await bumpUpProgress()
|
||||||
}
|
}
|
||||||
profileListener?.cancel()
|
profileListener?.cancel()
|
||||||
profileListener = Task {
|
profileListener = Task {
|
||||||
@@ -102,7 +102,7 @@ class ProfileModel: ObservableObject, Equatable {
|
|||||||
case .eose: break
|
case .eose: break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress += 1
|
await bumpUpProgress()
|
||||||
}
|
}
|
||||||
conversationListener?.cancel()
|
conversationListener?.cancel()
|
||||||
conversationListener = Task {
|
conversationListener = Task {
|
||||||
@@ -110,6 +110,11 @@ class ProfileModel: ObservableObject, Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func bumpUpProgress() {
|
||||||
|
progress += 1
|
||||||
|
}
|
||||||
|
|
||||||
func listenToConversations() async {
|
func listenToConversations() async {
|
||||||
// Only subscribe to conversation events if the profile is not us.
|
// Only subscribe to conversation events if the profile is not us.
|
||||||
guard pubkey != damus.pubkey else {
|
guard pubkey != damus.pubkey else {
|
||||||
|
|||||||
Reference in New Issue
Block a user