Interests: used filterIsInstance to find the TopicNavKey and get its ID instead of explicit type check and cast approach.

pull/2028/head
junior-od 8 months ago
parent 788672e29b
commit 31446c8e6c

@ -48,8 +48,9 @@ class InterestsViewModel @AssistedInject constructor(
private val selectedTopicId: StateFlow<String?> = private val selectedTopicId: StateFlow<String?> =
snapshotFlow { snapshotFlow {
navigationState.currentSubStack navigationState.currentSubStack
.lastOrNull { it is TopicNavKey } .filterIsInstance<TopicNavKey>()
?.let { (it as TopicNavKey).id } .lastOrNull()
?.id
}.stateIn( }.stateIn(
scope = viewModelScope, scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000), started = SharingStarted.WhileSubscribed(5_000),

Loading…
Cancel
Save