Event Preloading

Changelog-Added: Added event preloading when scrolling
Changelog-Added: Preload images so they don't pop in
Changelog-Fixed: Fixed preview elements popping in
Changelog-Changed: Cached various UI elements so its not as laggy
Changelog-Fixed: Fixed glitchy preview
This commit is contained in:
William Casarin
2023-04-30 19:31:14 -07:00
parent c87f19b479
commit 1ca0519e25
11 changed files with 532 additions and 192 deletions

View File

@@ -110,6 +110,7 @@ class NotificationsModel: ObservableObject, ScrollQueue {
var reposts: [String: EventGroup]
var replies: [NostrEvent]
var has_reply: Set<String>
var has_ev: Set<String>
@Published var notifications: [NotificationItem]
@@ -124,6 +125,7 @@ class NotificationsModel: ObservableObject, ScrollQueue {
self.incoming_events = []
self.profile_zaps = ZapGroup()
self.notifications = []
self.has_ev = Set()
}
func set_should_queue(_ val: Bool) {
@@ -265,8 +267,14 @@ class NotificationsModel: ObservableObject, ScrollQueue {
}
func insert_event(_ ev: NostrEvent, damus_state: DamusState) -> Bool {
if has_ev.contains(ev.id) {
return false
}
if should_queue {
return insert_uniq_sorted_event_created(events: &incoming_events, new_ev: ev)
incoming_events.append(ev)
has_ev.insert(ev.id)
return true
}
if insert_event_immediate(ev, cache: damus_state.events) {