diff --git a/app/src/main/java/io/github/wiiznokes/gitnote/ui/viewmodel/GridViewModel.kt b/app/src/main/java/io/github/wiiznokes/gitnote/ui/viewmodel/GridViewModel.kt index 3f0d13f..637ea45 100644 --- a/app/src/main/java/io/github/wiiznokes/gitnote/ui/viewmodel/GridViewModel.kt +++ b/app/src/main/java/io/github/wiiznokes/gitnote/ui/viewmodel/GridViewModel.kt @@ -209,12 +209,6 @@ class GridViewModel : ViewModel() { allNotes.filter { it.relativePath.startsWith(path) } - }.combine(query) { allNotesInCurrentPath, query -> - if (query.isNotEmpty()) { - fuzzySort(query, allNotesInCurrentPath) - } else { - allNotesInCurrentPath - } }.let { filteredNotesFlow -> combine( filteredNotesFlow, prefs.sortType.getFlow(), prefs.sortOrder.getFlow() @@ -232,6 +226,12 @@ class GridViewModel : ViewModel() { } } } + }.combine(query) { allNotesInCurrentPath, query -> + if (query.isNotEmpty()) { + fuzzySort(query, allNotesInCurrentPath) + } else { + allNotesInCurrentPath + } }.stateIn( CoroutineScope(Dispatchers.IO), SharingStarted.WhileSubscribed(5000), emptyList() )