Browse Source

Only reload global view on pulldown refresh

Changelog-Changed: Only reload global view on pulldown refresh
post-button-style
William Casarin 2 years ago
parent
commit
a4d62d295c
  1. 5
      damus/ContentView.swift
  2. 9
      damus/Models/SearchHomeModel.swift
  3. 7
      damus/Views/SearchHomeView.swift

5
damus/ContentView.swift

@ -68,6 +68,8 @@ struct ContentView: View {
@State var thread_open: Bool = false
@State var search_open: Bool = false
@State var filter_state : FilterState = .posts_and_replies
@StateObject var search: SearchHomeModel = SearchHomeModel()
@StateObject var home: HomeModel = HomeModel()
// connect retry timer
@ -133,7 +135,7 @@ struct ContentView: View {
}
switch selected_timeline {
case .search:
SearchHomeView(damus_state: damus_state!, model: SearchHomeModel(damus_state: damus_state!))
SearchHomeView(damus_state: damus_state!, model: search)
case .home:
PostingTimelineView
@ -403,6 +405,7 @@ struct ContentView: View {
dms: home.dms
)
home.damus_state = self.damus_state!
search.damus_state = self.damus_state!
pool.connect()
}

9
damus/Models/SearchHomeModel.swift

@ -10,17 +10,18 @@ import Foundation
/// The data model for the SearchHome view, typically something global-like
class SearchHomeModel: ObservableObject {
@Published var events: [NostrEvent] = []
@Published var events: [NostrEvent]
@Published var loading: Bool = false
var seen_pubkey: Set<String> = Set()
let damus_state: DamusState
var damus_state: DamusState
let base_subid = UUID().description
let profiles_subid = UUID().description
let limit: UInt32 = 250
init(damus_state: DamusState) {
self.damus_state = damus_state
init() {
self.events = []
self.damus_state = .empty
}
func get_base_filter() -> NostrFilter {

7
damus/Views/SearchHomeView.swift

@ -10,7 +10,7 @@ import CryptoKit
struct SearchHomeView: View {
let damus_state: DamusState
@StateObject var model: SearchHomeModel
@ObservedObject var model: SearchHomeModel
@State var search: String = ""
var SearchInput: some View {
@ -95,12 +95,15 @@ struct SearchHomeView: View {
}
}
/*
struct SearchHomeView_Previews: PreviewProvider {
static var previews: some View {
let state = test_damus_state()
SearchHomeView(
damus_state: state,
model: SearchHomeModel(damus_state: state)
model: SearchHomeModel()
)
}
}
*/

Loading…
Cancel
Save