Updated on 2026-08-14
This commit is contained in:
parent
4b72ca5252
commit
8611aca9e0
8 changed files with 80 additions and 7 deletions
|
|
@ -13,6 +13,8 @@ import com.tangem.tap.domain.TangemSdkManager
|
|||
import com.tangem.tap.domain.tokens.UserTokensRepository
|
||||
import com.tangem.tap.domain.walletStores.WalletStoresManager
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import org.rekotlin.Store
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -23,6 +25,15 @@ import javax.inject.Inject
|
|||
class AppStateHolder @Inject constructor() : WalletsStateHolder, NavigationStateHolder {
|
||||
|
||||
override var userWalletsListManager: UserWalletsListManager? = null
|
||||
set(value) {
|
||||
field = value
|
||||
_userWalletsListManagerFlow.value = value
|
||||
}
|
||||
|
||||
override val userWalletListManagerFlow: Flow<UserWalletsListManager?>
|
||||
get() = _userWalletsListManagerFlow
|
||||
|
||||
private val _userWalletsListManagerFlow = MutableStateFlow<UserWalletsListManager?>(null)
|
||||
|
||||
@Deprecated("Use scan response from selected user wallet")
|
||||
var scanResponse: ScanResponse? = null
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import dagger.Module
|
|||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.*
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
|
|
@ -58,8 +60,15 @@ class ProxyModule {
|
|||
@Singleton
|
||||
fun provideLear2earnDependencies(appStateHolder: AppStateHolder): Learn2earnDependencyProvider {
|
||||
return object : Learn2earnDependencyProvider {
|
||||
override fun getCardTypeResolver(): CardTypesResolver? {
|
||||
return appStateHolder.userWalletsListManager?.selectedUserWalletSync?.scanResponse?.cardTypesResolver
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun getCardTypeResolverFlow(): Flow<CardTypesResolver?> {
|
||||
return appStateHolder.userWalletListManagerFlow
|
||||
.flatMapLatest { manager ->
|
||||
manager?.selectedUserWallet
|
||||
?.map { it.scanResponse.cardTypesResolver }
|
||||
?: flowOf(null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLocaleProvider(): () -> String = { Locale.current.language }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue