fix(search): rebuild the results pager only when the dictionary set changes
Background metadata loading rewrote the dictionaries flow several times after startup, and every emission recreated the Pager: the results list visibly collapsed and refilled. Distinct on the index paths that paging actually uses, and seed the state synchronously instead of an empty list.
This commit is contained in:
1 parent
5c655e769c
commit
4b627b4d05
1 file changed
+3
-1
@@ -69,10 +69,12 @@ class SearchViewModel(
|
||||
private val activeDictionaries: StateFlow<List<com.example.research.core.domain.model.Dictionary>> =
|
||||
repository.dictionaries.map { dictList ->
|
||||
dictList.filter { it.isActive }
|
||||
}.distinctUntilChanged { previous, current ->
|
||||
previous.map { it.indexPath } == current.map { it.indexPath }
|
||||
}.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(5000),
|
||||
initialValue = emptyList()
|
||||
initialValue = repository.dictionaries.value.filter { it.isActive }
|
||||
)
|
||||
|
||||
init {
|
||||
|
||||
Reference in new issue
Block a user