diff --git a/src/App/Pages/Accounts/LoginPageViewModel.cs b/src/App/Pages/Accounts/LoginPageViewModel.cs index 9377daae5..9bf0ebe2a 100644 --- a/src/App/Pages/Accounts/LoginPageViewModel.cs +++ b/src/App/Pages/Accounts/LoginPageViewModel.cs @@ -130,14 +130,21 @@ namespace Bit.App.Pages public async Task InitAsync() { - await _deviceActionService.ShowLoadingAsync(AppResources.Loading); - if (string.IsNullOrWhiteSpace(Email)) + try { - Email = await _stateService.GetRememberedEmailAsync(); + await _deviceActionService.ShowLoadingAsync(AppResources.Loading); + if (string.IsNullOrWhiteSpace(Email)) + { + Email = await _stateService.GetRememberedEmailAsync(); + } + var deviceIdentifier = await _appIdService.GetAppIdAsync(); + IsKnownDevice = await _apiService.GetKnownDeviceAsync(Email, deviceIdentifier); + await _deviceActionService.HideLoadingAsync(); + } + catch (Exception ex) + { + HandleException(ex); } - var deviceIdentifier = await _appIdService.GetAppIdAsync(); - IsKnownDevice = await _apiService.GetKnownDeviceAsync(Email, deviceIdentifier); - await _deviceActionService.HideLoadingAsync(); } public async Task LogInAsync(bool showLoading = true, bool checkForExistingAccount = false) @@ -298,5 +305,15 @@ namespace Bit.App.Pages _messagingService.Send("switchedAccount"); } } + + private void HandleException(Exception ex) + { + Xamarin.Essentials.MainThread.InvokeOnMainThreadAsync(async () => + { + await _deviceActionService.HideLoadingAsync(); + await _platformUtilsService.ShowDialogAsync(AppResources.GenericErrorMessage); + }).FireAndForget(); + _logger.Exception(ex); + } } }