Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-19 09:28:57 +03:00
parent 6638da98f1
commit 4574975639
11 changed files with 130 additions and 22 deletions

View file

@ -8,7 +8,9 @@ import com.tangem.core.decompose.navigation.Router
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.wallets.usecase.ShouldSaveUserWalletsUseCase
import com.tangem.domain.wallets.usecase.UnlockWalletUseCase
import com.tangem.features.details.entity.UserWalletListUM
import com.tangem.features.details.impl.R
import com.tangem.features.details.utils.UserWalletSaver
@ -21,6 +23,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
@Suppress("LongParameterList")
@ -33,6 +37,7 @@ internal class UserWalletListModel @Inject constructor(
override val dispatchers: CoroutineDispatcherProvider,
private val userWalletSaver: UserWalletSaver,
private val hotWalletFeatureToggles: HotWalletFeatureToggles,
private val unlockWalletUseCase: UnlockWalletUseCase,
) : Model() {
private val isWalletSavingInProgress: MutableStateFlow<Boolean> = MutableStateFlow(value = false)
@ -40,7 +45,8 @@ internal class UserWalletListModel @Inject constructor(
messageSender = messageSender,
onlyMultiCurrency = false,
isAuthMode = false,
onWalletClick = { userWalletId -> router.push(AppRoute.WalletSettings(userWalletId)) },
isClickableIfLocked = hotWalletFeatureToggles.isHotWalletEnabled,
onWalletClick = ::onWalletClicked,
)
val state: MutableStateFlow<UserWalletListUM> = MutableStateFlow(
@ -87,4 +93,20 @@ internal class UserWalletListModel @Inject constructor(
}
}
}
private fun onWalletClicked(userWalletId: UserWalletId) {
if (hotWalletFeatureToggles.isHotWalletEnabled) {
modelScope.launch {
unlockWalletUseCase(userWalletId)
.onRight {
router.push(AppRoute.WalletSettings(userWalletId))
}
.onLeft { error ->
Timber.e("Failed to unlock wallet $userWalletId: $error")
}
}
} else {
router.push(AppRoute.WalletSettings(userWalletId))
}
}
}