nav: remove environmentObjects

environment objects are implicit arguments that cannot be checked by the
compiler. They are a common source of crashes. Use a main
NavigationCoordinator in DamusState for the core app, and pass in other
coordinators in the account setup view for the parts of the app that
don't have a DamusState.
This commit is contained in:
William Casarin
2023-06-30 09:59:58 -07:00
parent 9008c609e2
commit f702733654
29 changed files with 46 additions and 130 deletions
+1 -7
View File
@@ -14,7 +14,6 @@ struct SearchHomeView: View {
@StateObject var model: SearchHomeModel
@State var search: String = ""
@FocusState private var isFocused: Bool
@EnvironmentObject var navigationCoordinator: NavigationCoordinator
let preferredLanguages = Set(Locale.preferredLanguages.map { localeToLanguage($0) })
@@ -68,7 +67,6 @@ struct SearchHomeView: View {
return preferredLanguages.contains(note_lang)
}
)
.environmentObject(navigationCoordinator)
.refreshable {
// Fetch new information by unsubscribing and resubscribing to the relay
model.unsubscribe()
@@ -78,7 +76,6 @@ struct SearchHomeView: View {
var SearchContent: some View {
SearchResultsView(damus_state: damus_state, search: $search)
.environmentObject(navigationCoordinator)
.refreshable {
// Fetch new information by unsubscribing and resubscribing to the relay
model.unsubscribe()
@@ -129,9 +126,6 @@ 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)
)
SearchHomeView(damus_state: state, model: SearchHomeModel(damus_state: state))
}
}