Display error toast instead of spinning forever when trying to login for the first time with no network connected

This commit is contained in:
QuentinArguillere 2024-09-06 16:43:18 +02:00
parent 321e1065ac
commit df8f515601
2 changed files with 15 additions and 0 deletions

View file

@ -34,6 +34,14 @@ class AccountLoginViewModel: ObservableObject {
func login() {
coreContext.doOnCoreQueue { core in
guard self.coreContext.networkStatusIsConnected else {
DispatchQueue.main.async {
self.coreContext.loggingInProgress = false
ToastViewModel.shared.toastMessage = "Registration_failed_no_network"
ToastViewModel.shared.displayToast = true
}
return
}
do {
let usernameWithDomain = self.username.split(separator: "@")

View file

@ -129,6 +129,13 @@ struct ToastView: View {
.default_text_style(styleSize: 15)
.padding(8)
case "Registration_failed_no_network":
Text("Could not reach network")
.multilineTextAlignment(.center)
.foregroundStyle(Color.redDanger500)
.default_text_style(styleSize: 15)
.padding(8)
case "Success_account_logged_out":
Text("Account successfully logged out")
.multilineTextAlignment(.center)