summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-11-30 15:51:16 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-11-30 15:51:16 +0530
commitf0d09584fb398469b325900e9204eb632979e49f (patch)
tree61c4766dbcdb89802edf3525f78a033ad235815f
parent7475f2fb13f7f8b8e2bfbe48a58c2cca6b225392 (diff)
fix(android): add an implementation for Exact filter mode
Will be eventually exposed to the UI
-rw-r--r--app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt b/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
index 328641e6..cd7dbc78 100644
--- a/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
+++ b/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
@@ -94,18 +94,19 @@ val PasswordItem.stableId: String
enum class FilterMode {
NoFilter,
StrictDomain,
- Fuzzy
+ Fuzzy,
+ Exact,
}
enum class SearchMode {
RecursivelyInSubdirectories,
- InCurrentDirectoryOnly
+ InCurrentDirectoryOnly,
}
enum class ListMode {
FilesOnly,
DirectoriesOnly,
- AllEntries
+ AllEntries,
}
@OptIn(ExperimentalCoroutinesApi::class)
@@ -219,6 +220,16 @@ constructor(
.toList()
.sortedWith(itemComparator)
}
+ FilterMode.Exact -> {
+ prefilteredResultFlow
+ .filter { absoluteFile ->
+ absoluteFile.relativeTo(root).path.contains(searchAction.filter)
+ }
+ .map { it.toPasswordItem() }
+ .flowOn(dispatcherProvider.io())
+ .toList()
+ .sortedWith(itemComparator)
+ }
FilterMode.StrictDomain -> {
check(searchAction.listMode == ListMode.FilesOnly) {
"Searches with StrictDomain search mode can only list files"