damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 54dd2035a1311f83cb5b0c43581e7b970b6cea20
parent 587819c8eb6febc204e4a76250617e78d154ac05
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 20 Feb 2023 14:21:21 -0800

Always flush events when switching timelines

Diffstat:
Mdamus/Util/EventHolder.swift | 4++++
Mdamus/Views/TimelineView.swift | 8++++++--
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/damus/Util/EventHolder.swift b/damus/Util/EventHolder.swift @@ -79,6 +79,10 @@ class EventHolder: ObservableObject { } func flush() { + guard !incoming.isEmpty else { + return + } + var changed = false for event in incoming { if insert_uniq_sorted_event_created(events: &events, new_ev: event) { diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift @@ -56,14 +56,18 @@ struct TimelineView: View { .buttonStyle(BorderlessButtonStyle()) .coordinateSpace(name: "scroll") .onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in + let delay = events.has_incoming ? 0.1 : 0.0 + events.flush() guard let event = events.events.filter(self.filter).first else { return } self.events.should_queue = false - events.flush() - scroll_to_event(scroller: scroller, id: event.id, delay: 0.0, animate: true, anchor: .top) + scroll_to_event(scroller: scroller, id: event.id, delay: delay, animate: true, anchor: .top) } } + .onAppear { + events.flush() + } } }