Updated on 2026-08-14

This commit is contained in:
Tangem 2023-11-27 15:49:34 +08:00
parent 5384cf75ad
commit f89ba800e9
15 changed files with 489 additions and 22 deletions

View file

@ -0,0 +1,40 @@
package com.tangem.feature.wallet.presentation.wallet.loaders
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.loaders.implementors.MultiWalletContentLoaderFactory
import com.tangem.feature.wallet.presentation.wallet.loaders.implementors.SingleWalletContentLoaderFactory
import com.tangem.feature.wallet.presentation.wallet.loaders.implementors.SingleWalletWithTokenContentLoaderFactory
import com.tangem.feature.wallet.presentation.wallet.loaders.implementors.WalletContentLoader
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject
@ViewModelScoped
internal class WalletContentLoaderFactory @Inject constructor(
private val multiWalletContentLoaderFactory: MultiWalletContentLoaderFactory,
private val singleWalletWithTokenContentLoaderFactory: SingleWalletWithTokenContentLoaderFactory,
private val singleWalletContentLoaderFactory: SingleWalletContentLoaderFactory,
) {
fun create(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
isRefresh: Boolean = false,
): WalletContentLoader? {
return when {
userWallet.isMultiCurrency -> {
multiWalletContentLoaderFactory.create(userWallet, appCurrency, clickIntents)
}
userWallet.scanResponse.cardTypesResolver.isSingleWalletWithToken() -> {
singleWalletWithTokenContentLoaderFactory.create(userWallet, appCurrency, clickIntents)
}
!userWallet.isMultiCurrency -> {
singleWalletContentLoaderFactory.create(userWallet, appCurrency, clickIntents, isRefresh)
}
else -> null
}
}
}

View file

@ -0,0 +1,26 @@
package com.tangem.feature.wallet.presentation.wallet.loaders
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.Job
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
internal class WalletLoaderStorage @Inject constructor() {
private val loaders = ConcurrentHashMap<UserWalletId, List<Job>>()
fun contains(id: UserWalletId) = loaders.containsKey(id)
fun set(id: UserWalletId, jobs: List<Job>) {
loaders[id] = jobs
}
fun remove(id: UserWalletId) {
loaders[id]?.let {
it.forEach(Job::cancel)
loaders.remove(id)
}
}
}

View file

@ -0,0 +1,91 @@
package com.tangem.feature.wallet.presentation.wallet.loaders
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.CoroutineScope
import timber.log.Timber
import javax.inject.Inject
/**
* Base wallet screen content loader. Use it to load content by [UserWallet].
*
* @property factory factory that creates loader
* @property storage storage that save loader's jobs
* @property dispatchers coroutine dispatchers provider
*
[REDACTED_AUTHOR]
*/
@ViewModelScoped
internal class WalletScreenContentLoader @Inject constructor(
private val factory: WalletContentLoaderFactory,
private val storage: WalletLoaderStorage,
private val dispatchers: CoroutineDispatcherProvider,
) {
/**
* Load content by [UserWallet]
*
* @param userWallet user wallet
* @param appCurrency app currency
* @param clickIntents click intents
* @param isRefresh flag that determinate if content must load again
* @param coroutineScope coroutine scope
*/
fun load(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
isRefresh: Boolean = false,
coroutineScope: CoroutineScope,
) {
if (userWallet.isLocked) return
val id = userWallet.walletId
if (!storage.contains(id)) {
loadInternal(userWallet, appCurrency, clickIntents, coroutineScope, isRefresh)
} else {
if (isRefresh) {
storage.remove(id)
loadInternal(userWallet, appCurrency, clickIntents, coroutineScope, true)
} else {
Timber.d("$id content loading has already started")
}
}
}
/** Cancel loading by [id] */
fun cancel(id: UserWalletId) {
Timber.d("$id content loading is canceled")
storage.remove(id)
}
private fun loadInternal(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
coroutineScope: CoroutineScope,
isRefresh: Boolean,
) {
val loader = factory.create(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
isRefresh = isRefresh,
)
if (loader == null) {
Timber.e("Impossible to create loader for $userWallet")
return
}
Timber.d("${userWallet.walletId} content loading is ${if (isRefresh) "re" else ""}started")
loader.subscribers
.map { it.subscribe(coroutineScope, dispatchers) }
.let { storage.set(userWallet.walletId, it) }
}
}

View file

@ -0,0 +1,46 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.GetTokenListUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.subscribers.MultiWalletWarningsSubscriber
import com.tangem.feature.wallet.presentation.wallet.subscribers.TokenListSubscriber
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
@Suppress("LongParameterList")
internal class MultiWalletContentLoader(
private val userWallet: UserWallet,
private val appCurrency: AppCurrency,
private val clickIntents: WalletClickIntentsV2,
private val stateHolder: WalletStateHolderV2,
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
private val walletWithFundsChecker: WalletWithFundsChecker,
private val getTokenListUseCase: GetTokenListUseCase,
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
) : WalletContentLoader(id = userWallet.walletId) {
override fun create(): List<WalletSubscriber<*>> {
return listOf(
TokenListSubscriber(
userWallet = userWallet,
appCurrency = appCurrency,
stateHolder = stateHolder,
clickIntents = clickIntents,
tokenListAnalyticsSender = tokenListAnalyticsSender,
walletWithFundsChecker = walletWithFundsChecker,
getTokenListUseCase = getTokenListUseCase,
),
MultiWalletWarningsSubscriber(
userWalletId = userWallet.walletId,
stateHolder = stateHolder,
clickIntents = clickIntents,
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
),
)
}
}

View file

@ -0,0 +1,39 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.GetTokenListUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject
@ViewModelScoped
internal class MultiWalletContentLoaderFactory @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val getTokenListUseCase: GetTokenListUseCase,
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
private val walletWithFundsChecker: WalletWithFundsChecker,
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
) {
fun create(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
): WalletContentLoader {
return MultiWalletContentLoader(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
stateHolder = stateHolder,
tokenListAnalyticsSender = tokenListAnalyticsSender,
walletWithFundsChecker = walletWithFundsChecker,
getTokenListUseCase = getTokenListUseCase,
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
)
}
}

View file

@ -0,0 +1,66 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.settings.SetWalletWithFundsFoundUseCase
import com.tangem.domain.tokens.GetCryptoCurrencyActionsUseCase
import com.tangem.domain.tokens.GetPrimaryCurrencyStatusUpdatesUseCase
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.subscribers.*
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
@Suppress("LongParameterList")
internal class SingleWalletContentLoader(
private val userWallet: UserWallet,
private val appCurrency: AppCurrency,
private val clickIntents: WalletClickIntentsV2,
private val isRefresh: Boolean,
private val stateHolder: WalletStateHolderV2,
private val getPrimaryCurrencyStatusUpdatesUseCase: GetPrimaryCurrencyStatusUpdatesUseCase,
private val getCryptoCurrencyActionsUseCase: GetCryptoCurrencyActionsUseCase,
private val getSingleWalletWarningsFactory: GetSingleWalletWarningsFactory,
private val setWalletWithFundsFoundUseCase: SetWalletWithFundsFoundUseCase,
private val txHistoryItemsCountUseCase: GetTxHistoryItemsCountUseCase,
private val txHistoryItemsUseCase: GetTxHistoryItemsUseCase,
private val analyticsEventHandler: AnalyticsEventHandler,
) : WalletContentLoader(id = userWallet.walletId) {
override fun create(): List<WalletSubscriber<*>> {
return listOf(
PrimaryCurrencySubscriber(
userWallet = userWallet,
appCurrency = appCurrency,
stateHolder = stateHolder,
getPrimaryCurrencyStatusUpdatesUseCase = getPrimaryCurrencyStatusUpdatesUseCase,
setWalletWithFundsFoundUseCase = setWalletWithFundsFoundUseCase,
analyticsEventHandler = analyticsEventHandler,
),
SingleWalletButtonsSubscriber(
userWallet = userWallet,
stateHolder = stateHolder,
clickIntents = clickIntents,
getPrimaryCurrencyStatusUpdatesUseCase = getPrimaryCurrencyStatusUpdatesUseCase,
getCryptoCurrencyActionsUseCase = getCryptoCurrencyActionsUseCase,
),
SingleWalletNotificationsSubscriber(
userWalletId = userWallet.walletId,
stateHolder = stateHolder,
clickIntents = clickIntents,
getSingleWalletWarningsFactory = getSingleWalletWarningsFactory,
),
TxHistorySubscriber(
userWallet = userWallet,
isRefresh = isRefresh,
stateHolder = stateHolder,
clickIntents = clickIntents,
getPrimaryCurrencyStatusUpdatesUseCase = getPrimaryCurrencyStatusUpdatesUseCase,
txHistoryItemsCountUseCase = txHistoryItemsCountUseCase,
txHistoryItemsUseCase = txHistoryItemsUseCase,
),
)
}
}

View file

@ -0,0 +1,51 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.settings.SetWalletWithFundsFoundUseCase
import com.tangem.domain.tokens.GetCryptoCurrencyActionsUseCase
import com.tangem.domain.tokens.GetPrimaryCurrencyStatusUpdatesUseCase
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject
@ViewModelScoped
@Suppress("LongParameterList")
internal class SingleWalletContentLoaderFactory @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val getPrimaryCurrencyStatusUpdatesUseCase: GetPrimaryCurrencyStatusUpdatesUseCase,
private val getCryptoCurrencyActionsUseCase: GetCryptoCurrencyActionsUseCase,
private val getSingleWalletWarningsFactory: GetSingleWalletWarningsFactory,
private val setWalletWithFundsFoundUseCase: SetWalletWithFundsFoundUseCase,
private val txHistoryItemsCountUseCase: GetTxHistoryItemsCountUseCase,
private val txHistoryItemsUseCase: GetTxHistoryItemsUseCase,
private val analyticsEventHandler: AnalyticsEventHandler,
) {
fun create(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
isRefresh: Boolean,
): WalletContentLoader {
return SingleWalletContentLoader(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
isRefresh = isRefresh,
stateHolder = stateHolder,
getPrimaryCurrencyStatusUpdatesUseCase = getPrimaryCurrencyStatusUpdatesUseCase,
getCryptoCurrencyActionsUseCase = getCryptoCurrencyActionsUseCase,
getSingleWalletWarningsFactory = getSingleWalletWarningsFactory,
setWalletWithFundsFoundUseCase = setWalletWithFundsFoundUseCase,
txHistoryItemsCountUseCase = txHistoryItemsCountUseCase,
txHistoryItemsUseCase = txHistoryItemsUseCase,
analyticsEventHandler = analyticsEventHandler,
)
}
}

View file

@ -0,0 +1,46 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.GetCardTokensListUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.subscribers.MultiWalletWarningsSubscriber
import com.tangem.feature.wallet.presentation.wallet.subscribers.SingleWalletWithTokenListSubscriber
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
@Suppress("LongParameterList")
internal class SingleWalletWithTokenContentLoader(
private val userWallet: UserWallet,
private val appCurrency: AppCurrency,
private val clickIntents: WalletClickIntentsV2,
private val stateHolder: WalletStateHolderV2,
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
private val walletWithFundsChecker: WalletWithFundsChecker,
private val getCardTokensListUseCase: GetCardTokensListUseCase,
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
) : WalletContentLoader(id = userWallet.walletId) {
override fun create(): List<WalletSubscriber<*>> {
return listOf(
SingleWalletWithTokenListSubscriber(
userWallet = userWallet,
appCurrency = appCurrency,
stateHolder = stateHolder,
clickIntents = clickIntents,
tokenListAnalyticsSender = tokenListAnalyticsSender,
walletWithFundsChecker = walletWithFundsChecker,
getCardTokensListUseCase = getCardTokensListUseCase,
),
MultiWalletWarningsSubscriber(
userWalletId = userWallet.walletId,
stateHolder = stateHolder,
clickIntents = clickIntents,
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
),
)
}
}

View file

@ -0,0 +1,37 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.GetCardTokensListUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
import javax.inject.Inject
internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
private val walletWithFundsChecker: WalletWithFundsChecker,
private val getCardTokensListUseCase: GetCardTokensListUseCase,
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
) {
fun create(
userWallet: UserWallet,
appCurrency: AppCurrency,
clickIntents: WalletClickIntentsV2,
): SingleWalletWithTokenContentLoader {
return SingleWalletWithTokenContentLoader(
userWallet = userWallet,
appCurrency = appCurrency,
clickIntents = clickIntents,
stateHolder = stateHolder,
tokenListAnalyticsSender = tokenListAnalyticsSender,
walletWithFundsChecker = walletWithFundsChecker,
getCardTokensListUseCase = getCardTokensListUseCase,
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
)
}
}

View file

@ -0,0 +1,19 @@
package com.tangem.feature.wallet.presentation.wallet.loaders.implementors
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.feature.wallet.presentation.wallet.subscribers.WalletSubscriber
/**
* Wallet content loader
*
* @property id loader id
*
[REDACTED_AUTHOR]
*/
internal abstract class WalletContentLoader(val id: UserWalletId) {
/** Loader's subscribers */
val subscribers: List<WalletSubscriber<*>> get() = create()
protected abstract fun create(): List<WalletSubscriber<*>>
}

View file

@ -4,6 +4,7 @@ import com.tangem.core.navigation.AppScreen
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.domain.wallets.usecase.DeleteWalletUseCase
import com.tangem.domain.wallets.usecase.UpdateWalletUseCase
import com.tangem.feature.wallet.presentation.wallet.loaders.WalletScreenContentLoader
import com.tangem.feature.wallet.presentation.wallet.state.WalletAlertState
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletCardState
@ -27,7 +28,7 @@ internal interface WalletCardClickIntents {
internal class WalletCardClickIntentsImplementor @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val walletEventSender: WalletEventSender,
// TODO: private val walletScreenContentLoader: WalletScreenContentLoader,
private val walletScreenContentLoader: WalletScreenContentLoader,
private val updateWalletUseCase: UpdateWalletUseCase,
private val deleteWalletUseCase: DeleteWalletUseCase,
private val dispatchers: CoroutineDispatcherProvider,
@ -51,7 +52,7 @@ internal class WalletCardClickIntentsImplementor @Inject constructor(
override fun onDeleteAfterConfirmationClick(userWalletId: UserWalletId) {
viewModelScope.launch(dispatchers.main) {
// TODO: walletScreenContentLoader.cancel(userWalletId)
walletScreenContentLoader.cancel(userWalletId)
deleteWalletUseCase(userWalletId)
.onRight { popBackIfAllWalletsIsLocked() }
.onLeft { Timber.e(it.toString()) }

View file

@ -1,6 +1,7 @@
package com.tangem.feature.wallet.presentation.wallet.viewmodels.intents
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.settings.NeverToShowWalletsScrollPreview
import com.tangem.domain.tokens.FetchCardTokenListUseCase
@ -11,29 +12,29 @@ import com.tangem.domain.wallets.usecase.SelectWalletUseCase
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
import com.tangem.feature.wallet.presentation.wallet.analytics.PortfolioEvent
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.state2.WalletState
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateHolderV2
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.SetRefreshStateTransformer
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.SetTokenListErrorTransformer
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import javax.inject.Inject
/**
[REDACTED_AUTHOR]
*/
@Suppress("LongParameterList")
@ViewModelScoped
internal class WalletClickIntentsV2 @Inject constructor(
private val walletCardClickIntentsImplementor: WalletCardClickIntentsImplementor,
private val warningsClickIntentsImplementer: WalletWarningsClickIntentsImplementer,
private val currencyActionsClickIntentsImplementor: WalletCurrencyActionsClickIntentsImplementor,
private val contentClickIntentsImplementor: WalletContentClickIntentsImplementor,
private val stateHolder: WalletStateHolderV2,
// TODO: private val walletScreenContentLoader: WalletScreenContentLoader,
private val walletScreenContentLoader: WalletScreenContentLoader,
private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase,
private val selectWalletUseCase: SelectWalletUseCase,
// TODO: private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
private val fetchTokenListUseCase: FetchTokenListUseCase,
private val fetchCardTokenListUseCase: FetchCardTokenListUseCase,
private val fetchCurrencyStatusUseCase: FetchCurrencyStatusUseCase,
@ -66,13 +67,12 @@ internal class WalletClickIntentsV2 @Inject constructor(
stateHolder.update { it.copy(selectedWalletIndex = index) }
maybeUserWallet.onRight {
// TODO:
// walletScreenContentLoader.load(
// userWallet = it,
// appCurrency = getSelectedAppCurrencyUseCase.unwrap(),
// clickIntents = this@WalletClickIntentsV2,
// coroutineScope = viewModelScope,
// )
walletScreenContentLoader.load(
userWallet = it,
appCurrency = getSelectedAppCurrencyUseCase.unwrap(),
clickIntents = this@WalletClickIntentsV2,
coroutineScope = viewModelScope,
)
}
}
}
@ -133,14 +133,13 @@ internal class WalletClickIntentsV2 @Inject constructor(
viewModelScope.launch(dispatchers.main) {
fetchCurrencyStatusUseCase(userWallet.walletId, refresh = true)
// TODO:
// walletScreenContentLoader.load(
// userWallet = userWallet,
// appCurrency = getSelectedAppCurrencyUseCase.unwrap(),
// clickIntents = this@WalletClickIntentsV2,
// coroutineScope = viewModelScope,
// isRefresh = true,
// )
walletScreenContentLoader.load(
userWallet = userWallet,
appCurrency = getSelectedAppCurrencyUseCase.unwrap(),
clickIntents = this@WalletClickIntentsV2,
coroutineScope = viewModelScope,
isRefresh = true,
)
stateHolder.update(
SetRefreshStateTransformer(userWalletId = userWallet.walletId, isRefreshing = false),

View file

@ -19,6 +19,7 @@ import com.tangem.feature.wallet.presentation.wallet.state2.transformers.CloseBo
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.OpenBottomSheetTransformer
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.converter.MultiWalletCurrencyActionsConverter
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
@ -42,6 +43,7 @@ internal interface WalletContentClickIntents {
}
@Suppress("LongParameterList")
@ViewModelScoped
internal class WalletContentClickIntentsImplementor @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val currencyActionsClickIntentsImplementor: WalletCurrencyActionsClickIntentsImplementor,

View file

@ -37,6 +37,7 @@ import com.tangem.feature.wallet.presentation.wallet.state2.transformers.CloseBo
import com.tangem.feature.wallet.presentation.wallet.state2.transformers.OpenBottomSheetTransformer
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletEventSender
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.take
@ -65,6 +66,7 @@ interface WalletCurrencyActionsClickIntents {
}
@Suppress("LongParameterList", "LargeClass")
@ViewModelScoped
internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val walletEventSender: WalletEventSender,

View file

@ -38,6 +38,7 @@ import com.tangem.feature.wallet.presentation.wallet.state2.transformers.OpenBot
import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletEventSender
import com.tangem.operations.derivation.ExtendedPublicKeysMap
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.launch
import javax.inject.Inject
@ -63,6 +64,7 @@ internal interface WalletWarningsClickIntents {
}
@Suppress("LongParameterList")
@ViewModelScoped
internal class WalletWarningsClickIntentsImplementer @Inject constructor(
private val stateHolder: WalletStateHolderV2,
private val walletEventSender: WalletEventSender,