From 570d631ad3bea7fc6520dd4af9e280befdb0125f Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 17 Jan 2023 14:18:16 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../redux/WalletSelectorAction.kt | 2 -- .../redux/WalletSelectorMiddleware.kt | 36 ++++++++++++++----- .../redux/WalletSelectorReducer.kt | 1 - 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt index 0985f4b68c..17824db23f 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorAction.kt @@ -55,7 +55,5 @@ internal sealed interface WalletSelectorAction : Action { val fiatCurrency: FiatCurrency, ) : WalletSelectorAction - data class HandleError(val error: TangemError) : WalletSelectorAction - object CloseError : WalletSelectorAction } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt index 38832e455a..5b15d07266 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorMiddleware.kt @@ -29,7 +29,6 @@ import com.tangem.tap.userWalletsListManager import com.tangem.tap.walletStoresManager import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch import org.rekotlin.Middleware @@ -82,7 +81,6 @@ internal class WalletSelectorMiddleware { is WalletSelectorAction.UnlockWithBiometry.Success, is WalletSelectorAction.BalanceLoaded, is WalletSelectorAction.IsLockedChanged, - is WalletSelectorAction.HandleError, is WalletSelectorAction.CloseError, -> Unit } @@ -93,7 +91,6 @@ internal class WalletSelectorMiddleware { walletStoresManager.fetch(userWallets) .doOnFailure { error -> Timber.e(error, "Unable to fetch wallet stores") - store.dispatchOnMain(WalletSelectorAction.HandleError(error)) } } } @@ -126,6 +123,7 @@ internal class WalletSelectorMiddleware { scope.launch { userWalletsListManager.unlockWithBiometry() .doOnFailure { error -> + Timber.e(error, "Unable to unlock all user wallets") store.dispatchOnMain(WalletSelectorAction.UnlockWithBiometry.Error(error)) } .doOnSuccess { @@ -158,12 +156,14 @@ internal class WalletSelectorMiddleware { .doOnFailure { error -> // Rollback policy if card saving was failed tangemSdkManager.setAccessCodeRequestPolicy(prevUseBiometricsForAccessCode) + Timber.e(error, "Unable to save user wallet") store.dispatchOnMain(WalletSelectorAction.AddWallet.Error(error)) } }, onFailure = { error -> // Rollback policy if card scanning was failed tangemSdkManager.setAccessCodeRequestPolicy(prevUseBiometricsForAccessCode) + Timber.e(error, "Unable to scan card") store.dispatchOnMain(WalletSelectorAction.AddWallet.Error(error)) }, ) @@ -194,7 +194,13 @@ internal class WalletSelectorMiddleware { } } .doOnFailure { error -> - store.dispatchOnMain(WalletSelectorAction.HandleError(error)) + Timber.e( + error, + """ + Unable to select user wallet + |- Wallet ID to select: $userWalletId + """.trimIndent(), + ) } .doOnSuccess { val selectedUserWallet = userWalletsListManager.selectedUserWalletSync @@ -238,7 +244,14 @@ internal class WalletSelectorMiddleware { ) } .doOnFailure { error -> - store.dispatchOnMain(WalletSelectorAction.HandleError(error)) + Timber.e( + error, + """ + Unable to delete user wallets + |- Wallets IDs to delete: $userWalletsIds + |- Current wallets IDs: ${state.wallets.map { it.id }} + """.trimIndent(), + ) } } } @@ -249,7 +262,14 @@ internal class WalletSelectorMiddleware { scope.launch { userWalletsListManager.update(userWalletId) { it.copy(name = newName) } .doOnFailure { error -> - store.dispatchOnMain(WalletSelectorAction.HandleError(error)) + Timber.e( + error, + """ + Unable to rename user wallet + |- Wallet ID: $userWalletId + |- New name: $newName + """.trimIndent(), + ) } } } @@ -257,10 +277,10 @@ internal class WalletSelectorMiddleware { private fun refreshUserWalletsAmounts() { scope.launch { walletStoresManager.updateAmounts( - userWallets = userWalletsListManager.userWallets.first(), + userWallets = userWalletsListManager.userWallets.firstOrNull().orEmpty(), ) .doOnFailure { error -> - store.dispatchOnMain(WalletSelectorAction.HandleError(error)) + Timber.e(error, "Unable to refresh user wallets amounts") } } } diff --git a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt index b64fe0a3ce..9a8ba16eae 100644 --- a/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/walletSelector/redux/WalletSelectorReducer.kt @@ -27,7 +27,6 @@ internal object WalletSelectorReducer { is WalletSelectorAction.BalanceLoaded -> state.copy( wallets = state.wallets.updateWithBalance(action.userWalletModel), ) - is WalletSelectorAction.HandleError -> state.copy(error = action.error) is WalletSelectorAction.CloseError -> state.copy(error = null) is WalletSelectorAction.UnlockWithBiometry -> state.copy( isUnlockInProgress = true,