Skip to content

Commit a42b588

Browse files
authored
Merge pull request #921 from soramitsu/fixes/staking_alerts
fixes/staking_alerts
2 parents 7340591 + ac009ff commit a42b588

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ apply from: './scripts/secrets.gradle'
33
buildscript {
44
ext {
55
// App version
6-
versionName = '2.2.3'
7-
versionCode = 92
6+
versionName = '2.2.4'
7+
versionCode = 93
88

99
// SDK and tools
1010
compileSdkVersion = 33

feature-staking-impl/src/main/java/jp/co/soramitsu/staking/impl/domain/alerts/AlertsInteractor.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import jp.co.soramitsu.wallet.impl.domain.model.Asset
1616
import jp.co.soramitsu.wallet.impl.domain.model.amountFromPlanks
1717
import kotlinx.coroutines.flow.Flow
1818
import 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
2221
import java.math.BigDecimal
2322
import java.math.BigInteger
2423
import 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

Comments
 (0)