Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-18 12:07:31 +03:00
parent 910c869cff
commit c0b13b5a82
4 changed files with 12 additions and 5 deletions

View file

@ -11,6 +11,7 @@ import com.tangem.domain.wallets.legacy.WalletsStateHolder
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.tap.common.entities.FiatCurrency
import com.tangem.tap.common.extensions.dispatchOnMain
import com.tangem.tap.common.extensions.dispatchWithMain
import com.tangem.tap.common.extensions.onUserWalletSelected
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.domain.TangemSdkManager
@ -69,6 +70,10 @@ class AppStateHolder @Inject constructor() : WalletsStateHolder, ReduxNavControl
mainStore?.dispatch(action)
}
override suspend fun dispatchWithMain(action: Action) {
mainStore?.dispatchWithMain(action)
}
override suspend fun onUserWalletSelected(userWallet: UserWallet) {
mainStore?.onUserWalletSelected(userWallet)
}

View file

@ -7,5 +7,7 @@ interface ReduxStateHolder {
fun dispatch(action: Action)
suspend fun dispatchWithMain(action: Action)
suspend fun onUserWalletSelected(userWallet: UserWallet)
}

View file

@ -333,7 +333,7 @@ internal class TokenDetailsViewModel @Inject constructor(
val cryptoCurrencyStatus = cryptoCurrencyStatus ?: return
viewModelScope.launch(dispatchers.io) {
viewModelScope.launch(dispatchers.main) {
when (val currency = cryptoCurrencyStatus.currency) {
is CryptoCurrency.Coin -> {
reduxStateHolder.dispatch(
@ -363,7 +363,7 @@ internal class TokenDetailsViewModel @Inject constructor(
.distinctUntilChanged()
.firstOrNull()
reduxStateHolder.dispatch(
reduxStateHolder.dispatchWithMain(
action = TradeCryptoAction.New.SendToken(
userWallet = wallet,
tokenCurrency = tokenCurrency,

View file

@ -675,7 +675,7 @@ internal class WalletViewModel @Inject constructor(
.collectLatest {
it.onRight { coinStatus ->
uiState = stateFactory.getStateWithClosedBottomSheet()
reduxStateHolder.dispatch(
reduxStateHolder.dispatchWithMain(
action = TradeCryptoAction.New.SendToken(
userWallet = userWallet,
tokenCurrency = requireNotNull(cryptoCurrencyStatus.currency as? CryptoCurrency.Token),
@ -1163,8 +1163,8 @@ internal class WalletViewModel @Inject constructor(
)
}
private fun setupWalletConnectOnWallet(userWallet: UserWallet) {
reduxStateHolder.dispatch(
private suspend fun setupWalletConnectOnWallet(userWallet: UserWallet) {
reduxStateHolder.dispatchWithMain(
action = WalletConnectActions.New.SetupUserChains(userWallet = userWallet),
)
}