Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-25 17:03:24 +04:00
parent 504d0276f9
commit d6fbc592c3
11 changed files with 120 additions and 18 deletions

View file

@ -36,19 +36,28 @@ class AdditionalFeedbackInfo {
var userWalletId: String = ""
// wallets
internal val walletsInfo = mutableListOf<EmailWalletInfo>()
internal var onSendErrorWalletInfo: EmailWalletInfo? = null
var walletsInfo = emptyList<EmailWalletInfo>()
private set
var onSendErrorWalletInfo: EmailWalletInfo? = null
private set
var signedHashesCount: String = ""
private set
// device
var phoneModel: String = Build.MODEL
private set
var osVersion: String = Build.VERSION.SDK_INT.toString()
private set
// send error
var destinationAddress: String = ""
private set
var amount: String = ""
private set
var fee: String = ""
private set
var token: String = ""
private set
private val Address.name: String
get() = type.javaClass.simpleName
@ -65,10 +74,7 @@ class AdditionalFeedbackInfo {
@Deprecated("Don't use it directly")
fun setWalletsInfo(walletManagers: List<WalletManager>) {
walletsInfo.clear()
walletManagers.forEach { manager ->
walletsInfo.add(createEmailWalletInfo(manager))
}
walletsInfo = walletManagers.map(::createEmailWalletInfo)
}
fun updateOnSendError(

View file

@ -176,6 +176,8 @@ private fun handleAction(action: Action, appState: () -> AppState?) {
walletCurrenciesManager.addListener(action.topUpController)
}
is GlobalAction.UpdateUserWalletsListManager -> {
val walletManagersFacade = store.state.daggerGraphState.get(DaggerGraphState::walletManagersFacade)
/*
* If implementation of the UserWalletsListManager is changed,
* then all observers of selectedUserWallet become irrelevant.
@ -183,13 +185,13 @@ private fun handleAction(action: Action, appState: () -> AppState?) {
action.manager.selectedUserWallet
.distinctUntilChanged()
.onEach { userWallet ->
Analytics.send(event = Basic.WalletOpened())
Analytics.send(Basic.WalletOpened())
store.state.globalState.feedbackManager?.infoHolder?.let { infoHolder ->
infoHolder.setCardInfo(data = userWallet.scanResponse)
infoHolder.setCardInfo(userWallet.scanResponse)
store.state.daggerGraphState.get(DaggerGraphState::walletManagersFacade)
.getAll(userWalletId = userWallet.walletId)
walletManagersFacade
.getAll(userWallet.walletId)
.onEach(infoHolder::setWalletsInfo)
.launchIn(scope)
}

View file

@ -63,9 +63,9 @@ internal object TokensDomainModule {
@ViewModelScoped
fun provideRemoveCurrencyUseCase(
currenciesRepository: CurrenciesRepository,
dispatchers: CoroutineDispatcherProvider,
walletManagersFacade: WalletManagersFacade,
): RemoveCurrencyUseCase {
return RemoveCurrencyUseCase(currenciesRepository, dispatchers)
return RemoveCurrencyUseCase(currenciesRepository, walletManagersFacade)
}
@Provides

View file

@ -403,7 +403,19 @@ object TokensMiddleware {
private suspend fun removeNewCurrenciesIfNeeded(userWalletId: UserWalletId, currencies: List<CryptoCurrency>) {
if (currencies.isEmpty()) return
val currenciesRepository = store.state.daggerGraphState.get(DaggerGraphState::currenciesRepository)
val walletManagersFacade = store.state.daggerGraphState.get(DaggerGraphState::walletManagersFacade)
currenciesRepository.removeCurrencies(userWalletId = userWalletId, currencies = currencies)
walletManagersFacade.remove(
userWalletId = userWalletId,
networks = currencies
.filterIsInstance<CryptoCurrency.Coin>()
.mapTo(hashSetOf(), CryptoCurrency::network),
)
walletManagersFacade.removeTokens(
userWalletId = userWalletId,
tokens = currencies.filterIsInstance<CryptoCurrency.Token>().toSet(),
)
}
}