Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-09 18:08:31 +03:00
parent 367d92f87b
commit 01bfe89632
5 changed files with 4 additions and 36 deletions

View file

@ -29,7 +29,7 @@ class UserTokensRepository(
// TODO("After adding DI") replace with CoroutineDispatcherProvider
suspend fun getUserTokens(card: CardDTO): List<Currency> = withContext(dispatchers.io) {
val userId = getUserWalletId(card) ?: return emptyList()
val userId = getUserWalletId(card) ?: return@withContext emptyList()
if (DemoHelper.isDemoCardId(card.cardId)) {
return@withContext loadTokensOffline(card, userId).ifEmpty(::loadDemoCurrencies)
}
@ -55,21 +55,14 @@ class UserTokensRepository(
// TODO("After adding DI") replace with CoroutineDispatcherProvider
suspend fun saveUserTokens(card: CardDTO, tokens: List<Currency>) = withContext(dispatchers.io) {
val userId = getUserWalletId(card) ?: return
val userId = getUserWalletId(card) ?: return@withContext
val userTokens = tokens.toUserTokensResponse()
tangemTechApi.saveUserTokens(userId, userTokens)
storageService.saveUserTokens(userId, userTokens)
}
suspend fun removeUserTokens(card: CardDTO) {
val userId = getUserWalletId(card) ?: return
val userTokens = emptyList<Currency>().toUserTokensResponse()
networkService.saveUserTokens(userId, userTokens)
storageService.saveUserTokens(userId, userTokens)
}
suspend fun loadBlockchainsToDerive(card: CardDTO): List<BlockchainNetwork> = withContext(dispatchers.io) {
val userId = getUserWalletId(card) ?: return emptyList()
val userId = getUserWalletId(card) ?: return@withContext emptyList()
val blockchainNetworks = loadTokensOffline(card = card, userId = userId).toBlockchainNetworks()
if (DemoHelper.isDemoCardId(card.cardId)) {

View file

@ -143,26 +143,6 @@ internal class DefaultWalletAmountsRepository(
}
}
private suspend fun fetchAmountsForUserWallet(
userWallet: UserWallet,
): CompletionResult<Unit> = withContext(Dispatchers.Default) {
val walletId = userWallet.walletId
val scanResponse = userWallet.scanResponse
val walletStores = walletStoresStorage.getAll()
.first()
.getOrElse(walletId) { emptyList() }
walletStores.map { walletStore ->
async {
// TODO: Find wallet manager via [com.tangem.tap.domain.walletStores.repository.WalletManagersRepository]
val walletManager = walletStore.walletManager
fetchAmountsForWalletStore(walletId, scanResponse, walletStore, walletManager)
}
}
.awaitAll()
.fold()
}
private suspend fun fetchAmountsForUserWallets(
userWallets: List<UserWallet>,
): CompletionResult<Unit> = withContext(Dispatchers.Default) {

View file

@ -20,6 +20,7 @@ import androidx.compose.material.IconToggleButton
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview

View file

@ -3,7 +3,6 @@ package com.tangem.tap.features.details.ui.resetcard
import com.tangem.tap.features.details.ui.cardsettings.TextReference
data class ResetCardScreenState(
@StringRes val descriptionResId: Int,
val accepted: Boolean = false,
val descriptionText: TextReference,
val onAcceptWarningToggleClick: (Boolean) -> Unit,

View file

@ -15,11 +15,6 @@ class ResetCardViewModel(private val store: Store<AppState>) {
?: TextReference.Str(value = "")
return ResetCardScreenState(
descriptionResId = if (state?.card?.backupStatus?.isActive == true) {
R.string.reset_card_with_backup_to_factory_message
} else {
R.string.reset_card_without_backup_to_factory_message
},
accepted = state?.resetConfirmed ?: false,
descriptionText = descriptionText,
onAcceptWarningToggleClick = { store.dispatch(DetailsAction.ResetToFactory.Confirm(it)) },