From df8f51560154f2ef3c1d15ac921d436309329f89 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Fri, 6 Sep 2024 16:43:18 +0200 Subject: [PATCH] Display error toast instead of spinning forever when trying to login for the first time with no network connected --- .../UI/Assistant/Viewmodel/AccountLoginViewModel.swift | 8 ++++++++ Linphone/UI/Main/Fragments/ToastView.swift | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift index 8172c9bfb..7b0e9a1e3 100644 --- a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift +++ b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift @@ -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: "@") diff --git a/Linphone/UI/Main/Fragments/ToastView.swift b/Linphone/UI/Main/Fragments/ToastView.swift index 7ef3d9d63..24a0c551b 100644 --- a/Linphone/UI/Main/Fragments/ToastView.swift +++ b/Linphone/UI/Main/Fragments/ToastView.swift @@ -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)