From db869b280793149b51b1e10d6b2c22e6553c2ae0 Mon Sep 17 00:00:00 2001 From: Elizaveta Semenova Date: Mon, 10 Jul 2023 13:16:04 +0300 Subject: [PATCH] [PWN-9032] Handle internet connection error on 2 striga screens --- p2p_wallet/Common/Extensions/NSError+Extensions.swift | 2 +- .../SecondStep/StrigaRegistrationSecondStepViewModel.swift | 5 +++++ .../EnterSMSCode/EnterSMSCodeViewModel.swift | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/p2p_wallet/Common/Extensions/NSError+Extensions.swift b/p2p_wallet/Common/Extensions/NSError+Extensions.swift index 4f62143e7c..e6be4fccf4 100644 --- a/p2p_wallet/Common/Extensions/NSError+Extensions.swift +++ b/p2p_wallet/Common/Extensions/NSError+Extensions.swift @@ -2,6 +2,6 @@ import Foundation extension NSError { var isNetworkConnectionError: Bool { - self.code == NSURLErrorNetworkConnectionLost || self.code == NSURLErrorNotConnectedToInternet || self.code == NSURLErrorDataNotAllowed + self.code == NSURLErrorNetworkConnectionLost || self.code == NSURLErrorNotConnectedToInternet || self.code == NSURLErrorDataNotAllowed || self.code == NSURLErrorTimedOut } } diff --git a/p2p_wallet/Scenes/Main/BankTransfer/StrigaRegistration/SecondStep/StrigaRegistrationSecondStepViewModel.swift b/p2p_wallet/Scenes/Main/BankTransfer/StrigaRegistration/SecondStep/StrigaRegistrationSecondStepViewModel.swift index 7e16ef94ed..0157b47184 100644 --- a/p2p_wallet/Scenes/Main/BankTransfer/StrigaRegistration/SecondStep/StrigaRegistrationSecondStepViewModel.swift +++ b/p2p_wallet/Scenes/Main/BankTransfer/StrigaRegistration/SecondStep/StrigaRegistrationSecondStepViewModel.swift @@ -190,6 +190,11 @@ private extension StrigaRegistrationSecondStepViewModel { self.openHardError.send(()) } await logAlertMessage(error: BankTransferError.mobileAlreadyExists) + } catch let error as NSError where error.isNetworkConnectionError { + notificationService.showConnectionErrorNotification() + await MainActor.run { + self.isLoading = false + } } catch { self.notificationService.showDefaultErrorNotification() await MainActor.run { diff --git a/p2p_wallet/Scenes/Web3Auth/Onboarding/CreateWallet/Steps/EnterPhoneNumber/EnterSMSCode/EnterSMSCodeViewModel.swift b/p2p_wallet/Scenes/Web3Auth/Onboarding/CreateWallet/Steps/EnterPhoneNumber/EnterSMSCode/EnterSMSCodeViewModel.swift index 7c9d55a301..a3d85d67f3 100644 --- a/p2p_wallet/Scenes/Web3Auth/Onboarding/CreateWallet/Steps/EnterPhoneNumber/EnterSMSCode/EnterSMSCodeViewModel.swift +++ b/p2p_wallet/Scenes/Web3Auth/Onboarding/CreateWallet/Steps/EnterPhoneNumber/EnterSMSCode/EnterSMSCodeViewModel.swift @@ -139,6 +139,8 @@ final class EnterSMSCodeViewModel: BaseOTPViewModel { default: self.showError(error: error) } + } else if (error as? NSError)?.isNetworkConnectionError == true { + self?.notificationService.showConnectionErrorNotification() } else if error is UndefinedAPIGatewayError { self?.notificationService.showDefaultErrorNotification() } else {