Optimize json processing and preloading
- Preload events when added to the EventHolder queue - Remove relative time formatting from preloader. Just do it when event appears - Process incoming json in a background queue by default Changelog-Fixed: Fix wrong relative times on events Changelog-Changed: Preload events when they are queued
This commit is contained in:
@@ -8,20 +8,27 @@
|
||||
import Foundation
|
||||
|
||||
class ProfileModel: ObservableObject, Equatable {
|
||||
var events: EventHolder = EventHolder()
|
||||
@Published var contacts: NostrEvent? = nil
|
||||
@Published var following: Int = 0
|
||||
@Published var relays: [String: RelayInfo]? = nil
|
||||
@Published var progress: Int = 0
|
||||
|
||||
var events: EventHolder
|
||||
let pubkey: String
|
||||
let damus: DamusState
|
||||
|
||||
|
||||
var seen_event: Set<String> = Set()
|
||||
var sub_id = UUID().description
|
||||
var prof_subid = UUID().description
|
||||
|
||||
init(pubkey: String, damus: DamusState) {
|
||||
self.pubkey = pubkey
|
||||
self.damus = damus
|
||||
self.events = EventHolder(on_queue: { ev in
|
||||
preload_events(state: damus, events: [ev])
|
||||
})
|
||||
}
|
||||
|
||||
func follows(pubkey: String) -> Bool {
|
||||
guard let contacts = self.contacts else {
|
||||
return false
|
||||
@@ -47,11 +54,6 @@ class ProfileModel: ObservableObject, Equatable {
|
||||
return .pubkey(pubkey)
|
||||
}
|
||||
|
||||
init(pubkey: String, damus: DamusState) {
|
||||
self.pubkey = pubkey
|
||||
self.damus = damus
|
||||
}
|
||||
|
||||
static func == (lhs: ProfileModel, rhs: ProfileModel) -> Bool {
|
||||
return lhs.pubkey == rhs.pubkey
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user