Skip to content

Commit

Permalink
fix: sort before filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiznokes committed Aug 29, 2024
1 parent 08f348a commit 9607e84
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
)
Expand Down

0 comments on commit 9607e84

Please sign in to comment.