damus

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

commit a4d62d295c79686c0989854bec89c0846f7cb006
parent f8dc9f42dd49171998260dcb2aabcca6f5a6fe89
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 26 Dec 2022 07:38:19 -0800

Only reload global view on pulldown refresh

Changelog-Changed: Only reload global view on pulldown refresh

Diffstat:
Mdamus/ContentView.swift | 5++++-
Mdamus/Models/SearchHomeModel.swift | 9+++++----
Mdamus/Views/SearchHomeView.swift | 7+++++--
3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/damus/ContentView.swift b/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() } diff --git a/damus/Models/SearchHomeModel.swift b/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 { diff --git a/damus/Views/SearchHomeView.swift b/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() ) } } + +*/