commit d49cf5a505a27585529c6824a0f136a73e7e848f
parent 89e01d823af0babc37a2b2d01ac72aec8d4355d0
Author: William Casarin <jb55@jb55.com>
Date: Tue, 16 Jan 2024 16:04:12 -0800
perf: debounce scroll queue
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift
@@ -15,6 +15,7 @@ struct TimelineView<Content: View>: View {
let show_friend_icon: Bool
let filter: (NostrEvent) -> Bool
let content: Content?
+ let debouncer: Debouncer
init(events: EventHolder, loading: Binding<Bool>, damus: DamusState, show_friend_icon: Bool, filter: @escaping (NostrEvent) -> Bool, content: (() -> Content)? = nil) {
self.events = events
@@ -22,6 +23,7 @@ struct TimelineView<Content: View>: View {
self.damus = damus
self.show_friend_icon = show_friend_icon
self.filter = filter
+ self.debouncer = Debouncer(interval: 0.5)
self.content = content?()
}
@@ -45,7 +47,9 @@ struct TimelineView<Content: View>: View {
.shimmer(loading)
.disabled(loading)
.background(GeometryReader { proxy -> Color in
- handle_scroll_queue(proxy, queue: self.events)
+ debouncer.debounce_immediate {
+ handle_scroll_queue(proxy, queue: self.events)
+ }
return Color.clear
})
}