@@ -16,9 +16,8 @@ import jp.co.soramitsu.wallet.impl.domain.model.Asset
1616import jp.co.soramitsu.wallet.impl.domain.model.amountFromPlanks
1717import kotlinx.coroutines.flow.Flow
1818import kotlinx.coroutines.flow.combine
19- import kotlinx.coroutines.flow.emitAll
20- import kotlinx.coroutines.flow.first
21- import kotlinx.coroutines.flow.flow
19+ import kotlinx.coroutines.flow.flatMapLatest
20+ import kotlinx.coroutines.flow.flowOf
2221import java.math.BigDecimal
2322import java.math.BigInteger
2423import jp.co.soramitsu.core.models.Asset as CoreAsset
@@ -116,12 +115,9 @@ class AlertsInteractor(
116115 ::produceSetValidatorsAlert
117116 )
118117
119- fun getAlertsFlow (stakingState : StakingState ): Flow <List <Alert >> = flow {
120- val (chain, chainAsset) = sharedState.assetWithChain.first()
121-
118+ fun getAlertsFlow (stakingState : StakingState ): Flow <List <Alert >> = sharedState.assetWithChain.flatMapLatest { (chain, chainAsset) ->
122119 if (chainAsset.staking != CoreAsset .StakingType .RELAYCHAIN ) {
123- emit(emptyList())
124- return @flow
120+ return @flatMapLatest flowOf(emptyList())
125121 }
126122
127123 val maxRewardedNominatorsPerValidator = stakingConstantsRepository.maxRewardedNominatorPerValidator(chain.id)
@@ -146,7 +142,7 @@ class AlertsInteractor(
146142 alertProducers.mapNotNull { it.invoke(context) }
147143 }
148144
149- emitAll( alertsFlow)
145+ alertsFlow
150146 }
151147
152148 private inline fun <reified T : StakingState , R > requireState (
0 commit comments