@@ -59,8 +59,6 @@ struct ContentView: View {
|
|||||||
@State var profile_open: Bool = false
|
@State var profile_open: Bool = false
|
||||||
@State var thread_open: Bool = false
|
@State var thread_open: Bool = false
|
||||||
@State var search_open: Bool = false
|
@State var search_open: Bool = false
|
||||||
@State var filters_showing : Bool = false
|
|
||||||
@State var should_show_replies : Bool = true
|
|
||||||
@StateObject var home: HomeModel = HomeModel()
|
@StateObject var home: HomeModel = HomeModel()
|
||||||
|
|
||||||
// connect retry timer
|
// connect retry timer
|
||||||
@@ -88,52 +86,18 @@ struct ContentView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var FiltersView: some View {
|
|
||||||
VStack{
|
|
||||||
HStack{
|
|
||||||
Toggle("Show Replies", isOn: $should_show_replies)
|
|
||||||
.toggleStyle(SwitchToggleStyle(tint: .purple))
|
|
||||||
.padding(.leading,30)
|
|
||||||
.padding(.trailing,30)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var PostingTimelineView: some View {
|
var PostingTimelineView: some View {
|
||||||
VStack{
|
ZStack {
|
||||||
Label("", systemImage: "line.3.horizontal.decrease.circle.fill")
|
if let damus = self.damus_state {
|
||||||
.padding(.leading, 10)
|
TimelineView(events: $home.events, loading: $home.loading, damus: damus, show_friend_icon: false)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
|
||||||
.onTapGesture {
|
|
||||||
print("Filtering")
|
|
||||||
self.filters_showing = !self.filters_showing
|
|
||||||
}
|
|
||||||
if(filters_showing){
|
|
||||||
FiltersView
|
|
||||||
}
|
}
|
||||||
ZStack {
|
if privkey != nil {
|
||||||
if let damus = self.damus_state {
|
PostButtonContainer {
|
||||||
TimelineView(events: $home.events, loading: $home.loading, damus: damus, show_friend_icon: false, filter: filter_event)
|
self.active_sheet = .post
|
||||||
//TODO: Add filter function to the events to keep out replies if should_show_replies is false!
|
|
||||||
}
|
|
||||||
if privkey != nil {
|
|
||||||
PostButtonContainer {
|
|
||||||
self.active_sheet = .post
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func filter_event(_ ev: NostrEvent) -> Bool {
|
|
||||||
if !should_show_replies {
|
|
||||||
return !ev.is_reply(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func MainContent(damus: DamusState) -> some View {
|
func MainContent(damus: DamusState) -> some View {
|
||||||
@@ -155,7 +119,7 @@ struct ContentView: View {
|
|||||||
PostingTimelineView
|
PostingTimelineView
|
||||||
|
|
||||||
case .notifications:
|
case .notifications:
|
||||||
TimelineView(events: $home.notifications, loading: $home.loading, damus: damus, show_friend_icon: true, filter: { _ in true })
|
TimelineView(events: $home.notifications, loading: $home.loading, damus: damus, show_friend_icon: true)
|
||||||
.navigationTitle("Notifications")
|
.navigationTitle("Notifications")
|
||||||
|
|
||||||
case .dms:
|
case .dms:
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ struct ProfileView: View {
|
|||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
|
|
||||||
InnerTimelineView(events: $profile.events, damus: damus_state, show_friend_icon: false, filter: { _ in true })
|
InnerTimelineView(events: $profile.events, damus: damus_state, show_friend_icon: false)
|
||||||
}
|
}
|
||||||
.frame(maxHeight: .infinity, alignment: .topLeading)
|
.frame(maxHeight: .infinity, alignment: .topLeading)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct SearchHomeView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var GlobalContent: some View {
|
var GlobalContent: some View {
|
||||||
TimelineView(events: $model.events, loading: $model.loading, damus: damus_state, show_friend_icon: true, filter: { _ in true })
|
TimelineView(events: $model.events, loading: $model.loading, damus: damus_state, show_friend_icon: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
var SearchContent: some View {
|
var SearchContent: some View {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct SearchView: View {
|
|||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
TimelineView(events: $search.events, loading: $search.loading, damus: appstate, show_friend_icon: true, filter: { _ in true })
|
TimelineView(events: $search.events, loading: $search.loading, damus: appstate, show_friend_icon: true)
|
||||||
.navigationBarTitle(describe_search(search.search))
|
.navigationBarTitle(describe_search(search.search))
|
||||||
.padding([.leading, .trailing], 6)
|
.padding([.leading, .trailing], 6)
|
||||||
.onReceive(handle_notify(.switched_timeline)) { obj in
|
.onReceive(handle_notify(.switched_timeline)) { obj in
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ struct InnerTimelineView: View {
|
|||||||
@Binding var events: [NostrEvent]
|
@Binding var events: [NostrEvent]
|
||||||
let damus: DamusState
|
let damus: DamusState
|
||||||
let show_friend_icon: Bool
|
let show_friend_icon: Bool
|
||||||
let filter: (NostrEvent) -> Bool
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
LazyVStack {
|
LazyVStack {
|
||||||
ForEach(events.filter(filter), id: \.id) { (ev: NostrEvent) in
|
ForEach(events, id: \.id) { (ev: NostrEvent) in
|
||||||
let tm = ThreadModel(event: inner_event_or_self(ev: ev), pool: damus.pool, privkey: damus.keypair.privkey)
|
let tm = ThreadModel(event: inner_event_or_self(ev: ev), pool: damus.pool, privkey: damus.keypair.privkey)
|
||||||
let is_chatroom = has_hashtag(ev.tags, hashtag: "chat")
|
let is_chatroom = has_hashtag(ev.tags, hashtag: "chat")
|
||||||
let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
|
let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom)
|
||||||
@@ -42,8 +41,6 @@ struct TimelineView: View {
|
|||||||
let damus: DamusState
|
let damus: DamusState
|
||||||
let show_friend_icon: Bool
|
let show_friend_icon: Bool
|
||||||
|
|
||||||
let filter: (NostrEvent) -> Bool
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
MainContent
|
MainContent
|
||||||
}
|
}
|
||||||
@@ -55,7 +52,7 @@ struct TimelineView: View {
|
|||||||
ProgressView()
|
ProgressView()
|
||||||
.progressViewStyle(.circular)
|
.progressViewStyle(.circular)
|
||||||
}
|
}
|
||||||
InnerTimelineView(events: $events, damus: damus, show_friend_icon: show_friend_icon, filter: filter)
|
InnerTimelineView(events: $events, damus: damus, show_friend_icon: show_friend_icon)
|
||||||
}
|
}
|
||||||
.onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in
|
.onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in
|
||||||
guard let event = events.first else {
|
guard let event = events.first else {
|
||||||
|
|||||||
Reference in New Issue
Block a user