Skip to content

Commit 6eaeb6d

Browse files
committed
Fix - crash when switching to rococo after opening staking on any other network
1 parent 20cd75f commit 6eaeb6d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

feature-staking-impl/src/main/java/jp/co/soramitsu/feature_staking_impl/data/repository/StakingRepositoryImpl.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import kotlinx.coroutines.channels.BufferOverflow
5858
import kotlinx.coroutines.flow.Flow
5959
import kotlinx.coroutines.flow.MutableSharedFlow
6060
import kotlinx.coroutines.flow.combine
61+
import kotlinx.coroutines.flow.filter
6162
import kotlinx.coroutines.flow.filterNotNull
6263
import kotlinx.coroutines.flow.flatMapLatest
6364
import kotlinx.coroutines.flow.flowOf
@@ -229,7 +230,13 @@ class StakingRepositoryImpl(
229230

230231
accountRepository.selectedNetworkTypeFlow()
231232
.onEach { exposuresFlow.resetReplayCache() } // invalidating cache on network change
232-
.flatMapLatest(::observeActiveEraIndex)
233+
.flatMapLatest { networkType ->
234+
runtimeProperty.observe()
235+
.filter { it.metadata.hasModule(Modules.STAKING) } // check that staking is supported
236+
.flatMapLatest { runtime ->
237+
storageCache.observeActiveEraIndex(runtime, networkType)
238+
}
239+
}
233240
.onEach { exposuresFlow.resetReplayCache() } // invalidating cache on era change
234241
.mapLatest(::getElectedValidatorsExposure)
235242
.onEach(exposuresFlow::emit)

0 commit comments

Comments
 (0)