mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Move Account-related error handling up the hierarchy
This commit is contained in:
parent
11200a01a0
commit
01ba57ae75
@ -88,16 +88,6 @@ struct AccountLoginView: View {
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.onChange(of: model.hasError) { value in
|
||||
if value {
|
||||
if let error = model.currentError {
|
||||
self.errorHandling.handle(error: error)
|
||||
} else {
|
||||
self.errorHandling.handle(error: AppError.genericError)
|
||||
}
|
||||
model.hasError = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import SwiftUI
|
||||
|
||||
struct AccountView: View {
|
||||
@EnvironmentObject var model: WriteFreelyModel
|
||||
@EnvironmentObject var errorHandling: ErrorHandling
|
||||
|
||||
var body: some View {
|
||||
if model.account.isLoggedIn {
|
||||
@ -16,6 +17,17 @@ struct AccountView: View {
|
||||
.withErrorHandling()
|
||||
.padding(.top)
|
||||
}
|
||||
EmptyView()
|
||||
.onChange(of: model.hasError) { value in
|
||||
if value {
|
||||
if let error = model.currentError {
|
||||
self.errorHandling.handle(error: error)
|
||||
} else {
|
||||
self.errorHandling.handle(error: AppError.genericError)
|
||||
}
|
||||
model.hasError = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ struct SettingsView: View {
|
||||
Form {
|
||||
Section(header: Text("Login Details")) {
|
||||
AccountView()
|
||||
.withErrorHandling()
|
||||
}
|
||||
Section(header: Text("Appearance")) {
|
||||
PreferencesView(preferences: model.preferences)
|
||||
|
Loading…
Reference in New Issue
Block a user