Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit f0d0958

Browse files
committed
fix(android): add an implementation for Exact filter mode
Will be eventually exposed to the UI
1 parent 7475f2f commit f0d0958

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,19 @@ val PasswordItem.stableId: String
9494
enum class FilterMode {
9595
NoFilter,
9696
StrictDomain,
97-
Fuzzy
97+
Fuzzy,
98+
Exact,
9899
}
99100

100101
enum class SearchMode {
101102
RecursivelyInSubdirectories,
102-
InCurrentDirectoryOnly
103+
InCurrentDirectoryOnly,
103104
}
104105

105106
enum class ListMode {
106107
FilesOnly,
107108
DirectoriesOnly,
108-
AllEntries
109+
AllEntries,
109110
}
110111

111112
@OptIn(ExperimentalCoroutinesApi::class)
@@ -219,6 +220,16 @@ constructor(
219220
.toList()
220221
.sortedWith(itemComparator)
221222
}
223+
FilterMode.Exact -> {
224+
prefilteredResultFlow
225+
.filter { absoluteFile ->
226+
absoluteFile.relativeTo(root).path.contains(searchAction.filter)
227+
}
228+
.map { it.toPasswordItem() }
229+
.flowOn(dispatcherProvider.io())
230+
.toList()
231+
.sortedWith(itemComparator)
232+
}
222233
FilterMode.StrictDomain -> {
223234
check(searchAction.listMode == ListMode.FilesOnly) {
224235
"Searches with StrictDomain search mode can only list files"

0 commit comments

Comments
 (0)