commit 5f22a7691ff7202f398fd57d0b4d0c52900ba844
parent d878ff6fdb763dc5efbc9056f94902673d22f514
Author: OlegAba <mail@olegaba.com>
Date: Fri, 6 Jan 2023 13:07:53 -0500
Fix TabView loading new view on scroll
Diffstat:
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
@@ -93,9 +93,9 @@ struct ContentView: View {
var PostingTimelineView: some View {
VStack {
TabView(selection: $filter_state) {
- ContentTimelineView
+ contentTimelineView(filter: posts_filter_event)
.tag(FilterState.posts)
- ContentTimelineView
+ contentTimelineView(filter: posts_and_replies_filter_event)
.tag(FilterState.posts_and_replies)
}
.tabViewStyle(.page(indexDisplayMode: .never))
@@ -113,10 +113,10 @@ struct ContentView: View {
.ignoresSafeArea(.keyboard)
}
- var ContentTimelineView: some View {
+ func contentTimelineView(filter: (@escaping (NostrEvent) -> Bool)) -> some View {
ZStack {
if let damus = self.damus_state {
- TimelineView(events: $home.events, loading: $home.loading, damus: damus, show_friend_icon: false, filter: filter_event)
+ TimelineView(events: $home.events, loading: $home.loading, damus: damus, show_friend_icon: false, filter: filter)
}
if privkey != nil {
PostButtonContainer {
@@ -126,6 +126,14 @@ struct ContentView: View {
}
}
+ func posts_and_replies_filter_event(_ ev: NostrEvent) -> Bool {
+ return true
+ }
+
+ func posts_filter_event(_ ev: NostrEvent) -> Bool {
+ return !ev.is_reply(nil)
+ }
+
var FiltersView: some View {
VStack{
Picker("Filter State", selection: $filter_state) {
@@ -136,14 +144,6 @@ struct ContentView: View {
}
}
- func filter_event(_ ev: NostrEvent) -> Bool {
- if self.filter_state == .posts {
- return !ev.is_reply(nil)
- }
-
- return true
- }
-
func MainContent(damus: DamusState) -> some View {
VStack {
NavigationLink(destination: MaybeProfileView, isActive: $profile_open) {