From c300a5eaf337e5bcc439f09cb2c9d9b6a03e93b2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 22 Apr 2025 13:58:07 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/child/wallet/model/WalletModel.kt | 30 ------------------- .../model/intents/WalletClickIntents.kt | 8 ----- .../SetNFTCollectionsTransformer.kt | 15 ++-------- 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 270806b3a2..56879b602c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -11,13 +11,11 @@ import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.decompose.model.Model import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase import com.tangem.domain.common.util.cardTypesResolver -import com.tangem.domain.nft.FetchNFTCollectionsUseCase import com.tangem.domain.settings.* import com.tangem.domain.tokens.FetchCurrencyStatusUseCase import com.tangem.domain.tokens.RefreshMultiCurrencyWalletQuotesUseCase import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId -import com.tangem.domain.wallets.repository.WalletsRepository import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase import com.tangem.domain.wallets.usecase.GetWalletsUseCase import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents @@ -45,7 +43,6 @@ import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION import com.tangem.features.pushnotifications.api.utils.getPushPermissionOrNull import com.tangem.utils.Provider import com.tangem.utils.coroutines.* -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch @@ -80,8 +77,6 @@ internal class WalletModel @Inject constructor( private val onrampStatusFactory: OnrampStatusFactory, private val biometryFeatureToggles: BiometryFeatureToggles, private val analyticsEventsHandler: AnalyticsEventHandler, - private val fetchNFTCollectionsUseCase: FetchNFTCollectionsUseCase, - private val walletsRepository: WalletsRepository, private val fetchCurrencyStatusUseCase: FetchCurrencyStatusUseCase, val screenLifecycleProvider: ScreenLifecycleProvider, val innerWalletRouter: InnerWalletRouter, @@ -93,7 +88,6 @@ internal class WalletModel @Inject constructor( private val walletsUpdateJobHolder = JobHolder() private val refreshWalletJobHolder = JobHolder() private val expressStatusJobHolder = JobHolder() - private val walletsNFTsUpdateJobHolder = JobHolder() private var needToRefreshWallet = false private var expressTxStatusTaskScheduler = SingleTaskScheduler() @@ -109,7 +103,6 @@ internal class WalletModel @Inject constructor( subscribeOnBalanceHiding() subscribeOnSelectedWalletFlow() subscribeOnPushNotificationsPermission() - subscribeOnNFTUpdates() clickIntents.initialize(innerWalletRouter, modelScope) } @@ -269,29 +262,6 @@ internal class WalletModel @Inject constructor( ) } - @OptIn(ExperimentalCoroutinesApi::class) - private fun subscribeOnNFTUpdates() { - getWalletsUseCase() - .conflate() - .distinctUntilChanged() - .flatMapLatest { wallets -> - wallets - .map { wallet -> - walletsRepository.nftEnabledStatus(wallet.walletId) - .distinctUntilChanged() - .onEach { nftEnabled -> - if (nftEnabled) { - fetchNFTCollectionsUseCase.invoke(wallet.walletId) - } - } - } - .merge() - } - .flowOn(dispatchers.main) - .launchIn(modelScope) - .saveIn(walletsNFTsUpdateJobHolder) - } - private fun needToRefreshTimer() { modelScope.launch { delay(REFRESH_WALLET_BACKGROUND_TIMER_MILLIS) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt index ee324b252e..e39efc204f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletClickIntents.kt @@ -5,7 +5,6 @@ import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.extenstions.unwrap import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.exchange.RampStateManager -import com.tangem.domain.nft.FetchNFTCollectionsUseCase import com.tangem.domain.onramp.FetchHotCryptoUseCase import com.tangem.domain.settings.NeverToShowWalletsScrollPreview import com.tangem.domain.tokens.FetchCardTokenListUseCase @@ -15,7 +14,6 @@ import com.tangem.domain.tokens.FetchTokenListUseCase.RefreshMode import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.SelectWalletUseCase import com.tangem.feature.wallet.presentation.router.InnerWalletRouter -import com.tangem.feature.wallet.presentation.wallet.domain.IsWalletNFTEnabledSyncUseCase import com.tangem.feature.wallet.presentation.wallet.domain.unwrap import com.tangem.feature.wallet.presentation.wallet.loaders.WalletScreenContentLoader import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController @@ -52,8 +50,6 @@ internal class WalletClickIntents @Inject constructor( private val dispatchers: CoroutineDispatcherProvider, private val onrampFeatureToggles: OnrampFeatureToggles, private val fetchHotCryptoUseCase: FetchHotCryptoUseCase, - private val fetchNFTCollectionsUseCase: FetchNFTCollectionsUseCase, - private val isWalletNFTEnabledSyncUseCase: IsWalletNFTEnabledSyncUseCase, ) : BaseWalletClickIntents(), WalletCardClickIntents by walletCardClickIntentsImplementor, WalletWarningsClickIntents by warningsClickIntentsImplementer, @@ -142,10 +138,6 @@ internal class WalletClickIntents @Inject constructor( async { rampStateManager.fetchSellServiceData() }.let(::add) async { fetchHotCryptoUseCase() }.let(::add) - - if (isWalletNFTEnabledSyncUseCase.invoke(userWallet.walletId)) { - async { fetchNFTCollectionsUseCase(userWalletId = userWallet.walletId) }.let(::add) - } } .awaitAll() diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetNFTCollectionsTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetNFTCollectionsTransformer.kt index 9c5fcb1479..b749ffccf3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetNFTCollectionsTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetNFTCollectionsTransformer.kt @@ -1,6 +1,5 @@ package com.tangem.feature.wallet.presentation.wallet.state.transformers -import com.tangem.domain.models.StatusSource import com.tangem.domain.nft.models.* import com.tangem.domain.wallets.models.UserWalletId import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNFTItemUM @@ -16,14 +15,8 @@ internal class SetNFTCollectionsTransformer( override fun transform(prevState: WalletState): WalletState = when (prevState) { is WalletState.MultiCurrency.Content -> prevState.copy( nftState = when { - nftCollections.allCollectionsFailed() -> - WalletNFTItemUM.Failed - nftCollections.anyCollectionFailed() && nftCollections.allLoadedCollectionsEmpty() -> - WalletNFTItemUM.Failed - nftCollections.allCollectionsLoaded() && nftCollections.allCollectionsEmpty() -> + nftCollections.allLoadedCollectionsEmpty() -> WalletNFTItemUM.Empty(onItemClick) - !nftCollections.allCollectionsLoaded() && nftCollections.allCollectionsEmpty() -> - WalletNFTItemUM.Loading else -> createContentNFTItemUM(onItemClick) }, ) @@ -41,10 +34,6 @@ internal class SetNFTCollectionsTransformer( .map { it.content } .filterIsInstance() - val isFlickering = collectionsContent - .map { it.source } - .any { it == StatusSource.CACHE } - val collections = collectionsContent .mapNotNull { it.collections } .flatten() @@ -65,7 +54,7 @@ internal class SetNFTCollectionsTransformer( collectionsCount = collections.size, assetsCount = collections .sumOf { it.count }, - isFlickering = isFlickering, + isFlickering = false, onItemClick = onItemClick, ) }