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()
|
.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 {
|
struct AccountView: View {
|
||||||
@EnvironmentObject var model: WriteFreelyModel
|
@EnvironmentObject var model: WriteFreelyModel
|
||||||
|
@EnvironmentObject var errorHandling: ErrorHandling
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if model.account.isLoggedIn {
|
if model.account.isLoggedIn {
|
||||||
@ -16,6 +17,17 @@ struct AccountView: View {
|
|||||||
.withErrorHandling()
|
.withErrorHandling()
|
||||||
.padding(.top)
|
.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 {
|
Form {
|
||||||
Section(header: Text("Login Details")) {
|
Section(header: Text("Login Details")) {
|
||||||
AccountView()
|
AccountView()
|
||||||
|
.withErrorHandling()
|
||||||
}
|
}
|
||||||
Section(header: Text("Appearance")) {
|
Section(header: Text("Appearance")) {
|
||||||
PreferencesView(preferences: model.preferences)
|
PreferencesView(preferences: model.preferences)
|
||||||
|
Loading…
Reference in New Issue
Block a user