From 01ba57ae759c87a6ac40050f39bfa9e85e46c103 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sun, 8 May 2022 09:16:46 -0400 Subject: [PATCH] Move Account-related error handling up the hierarchy --- Shared/Account/AccountLoginView.swift | 10 ---------- Shared/Account/AccountView.swift | 12 ++++++++++++ iOS/Settings/SettingsView.swift | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Shared/Account/AccountLoginView.swift b/Shared/Account/AccountLoginView.swift index c7ea5ea..64e7971 100644 --- a/Shared/Account/AccountLoginView.swift +++ b/Shared/Account/AccountLoginView.swift @@ -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 - } - } } } diff --git a/Shared/Account/AccountView.swift b/Shared/Account/AccountView.swift index 9241026..0a2546e 100644 --- a/Shared/Account/AccountView.swift +++ b/Shared/Account/AccountView.swift @@ -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 + } + } } } diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index e64bc94..28c55a6 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -9,6 +9,7 @@ struct SettingsView: View { Form { Section(header: Text("Login Details")) { AccountView() + .withErrorHandling() } Section(header: Text("Appearance")) { PreferencesView(preferences: model.preferences)