perf: debounce scroll queue
This commit is contained in:
@@ -15,6 +15,7 @@ struct TimelineView<Content: View>: View {
|
|||||||
let show_friend_icon: Bool
|
let show_friend_icon: Bool
|
||||||
let filter: (NostrEvent) -> Bool
|
let filter: (NostrEvent) -> Bool
|
||||||
let content: Content?
|
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) {
|
init(events: EventHolder, loading: Binding<Bool>, damus: DamusState, show_friend_icon: Bool, filter: @escaping (NostrEvent) -> Bool, content: (() -> Content)? = nil) {
|
||||||
self.events = events
|
self.events = events
|
||||||
@@ -22,6 +23,7 @@ struct TimelineView<Content: View>: View {
|
|||||||
self.damus = damus
|
self.damus = damus
|
||||||
self.show_friend_icon = show_friend_icon
|
self.show_friend_icon = show_friend_icon
|
||||||
self.filter = filter
|
self.filter = filter
|
||||||
|
self.debouncer = Debouncer(interval: 0.5)
|
||||||
self.content = content?()
|
self.content = content?()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +47,9 @@ struct TimelineView<Content: View>: View {
|
|||||||
.shimmer(loading)
|
.shimmer(loading)
|
||||||
.disabled(loading)
|
.disabled(loading)
|
||||||
.background(GeometryReader { proxy -> Color in
|
.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
|
return Color.clear
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user