From d47f3f7d52486bf49e1abe7c1beebfeb07e60e08 Mon Sep 17 00:00:00 2001 From: kabramovp2p <99185280+kabramovp2p@users.noreply.github.com> Date: Thu, 29 Jun 2023 10:39:57 +0300 Subject: [PATCH] PWN-9092 - fix error handling on update share (#1895) --- .../org/p2p/wallet/settings/ui/devices/DevicesPresenter.kt | 7 ++++--- .../settings/ui/mail/SettingsEmailConfirmPresenter.kt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/p2p/wallet/settings/ui/devices/DevicesPresenter.kt b/app/src/main/java/org/p2p/wallet/settings/ui/devices/DevicesPresenter.kt index 52335a791b..442ece0f57 100644 --- a/app/src/main/java/org/p2p/wallet/settings/ui/devices/DevicesPresenter.kt +++ b/app/src/main/java/org/p2p/wallet/settings/ui/devices/DevicesPresenter.kt @@ -38,10 +38,7 @@ class DevicesPresenter( val isTorusKeyValid = restoreFlowDataLocalRepository.isTorusKeyValid() if (isTorusKeyValid) { launch { - view?.setLoadingState(isScreenLoading = true) updateDeviceShare() - view?.setLoadingState(isScreenLoading = false) - view?.showSuccessDeviceChange() } } else { submitUserPhoneNumber() @@ -58,12 +55,16 @@ class DevicesPresenter( } private suspend fun refreshDeviceShare(newMetadata: GatewayOnboardingMetadata) { + view?.setLoadingState(isScreenLoading = true) try { restoreWalletInteractor.refreshDeviceShare() metadataInteractor.updateMetadata(newMetadata) + view?.showSuccessDeviceChange() } catch (error: Throwable) { view?.showFailDeviceChange() Timber.e(error, "Error on refreshDeviceShare") + } finally { + view?.setLoadingState(isScreenLoading = false) } } diff --git a/app/src/main/java/org/p2p/wallet/settings/ui/mail/SettingsEmailConfirmPresenter.kt b/app/src/main/java/org/p2p/wallet/settings/ui/mail/SettingsEmailConfirmPresenter.kt index a2c620f693..d488f181bb 100644 --- a/app/src/main/java/org/p2p/wallet/settings/ui/mail/SettingsEmailConfirmPresenter.kt +++ b/app/src/main/java/org/p2p/wallet/settings/ui/mail/SettingsEmailConfirmPresenter.kt @@ -65,13 +65,13 @@ class SettingsEmailConfirmPresenter( deviceNameTimestampSec = DateTimeUtils.getCurrentTimestampInSeconds() ) refreshDeviceShare(newMetadata) - view?.showSuccessDeviceChange() } private suspend fun refreshDeviceShare(newMetadata: GatewayOnboardingMetadata) { try { restoreWalletInteractor.refreshDeviceShare() metadataInteractor.updateMetadata(newMetadata) + view?.showSuccessDeviceChange() } catch (error: Throwable) { view?.showFailDeviceChange() Timber.e(error, "Error on refreshDeviceShare")