mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Use an enum instead of a boolean to differentiate search
It's not very likely to have more modes of search besides normal and trashed, but got surprised in that way quite often and it's nicer this way anyways.
This commit is contained in:
@ -87,11 +87,11 @@ object OSimpleSearch {
|
||||
useFTS: Boolean,
|
||||
resolveDetails: Boolean,
|
||||
maxNoteLen: Int,
|
||||
deleted: Boolean
|
||||
searchMode: SearchMode
|
||||
)
|
||||
final case class StatsSettings(
|
||||
useFTS: Boolean,
|
||||
deleted: Boolean
|
||||
searchMode: SearchMode
|
||||
)
|
||||
|
||||
sealed trait Items {
|
||||
@ -223,8 +223,10 @@ object OSimpleSearch {
|
||||
// 2. sql+fulltext if fulltextQuery.isDefined && q.nonEmpty && useFTS
|
||||
// 3. sql-only else (if fulltextQuery.isEmpty || !useFTS)
|
||||
val validItemQuery =
|
||||
if (settings.deleted) q.withFix(_.andQuery(ItemQuery.Expr.Trashed))
|
||||
else q.withFix(_.andQuery(ItemQuery.Expr.ValidItemStates))
|
||||
settings.searchMode match {
|
||||
case SearchMode.Trashed => q.withFix(_.andQuery(ItemQuery.Expr.Trashed))
|
||||
case SearchMode.Normal => q.withFix(_.andQuery(ItemQuery.Expr.ValidItemStates))
|
||||
}
|
||||
fulltextQuery match {
|
||||
case Some(ftq) if settings.useFTS =>
|
||||
if (q.isEmpty) {
|
||||
@ -280,8 +282,10 @@ object OSimpleSearch {
|
||||
settings: StatsSettings
|
||||
)(q: Query, fulltextQuery: Option[String]): F[SearchSummary] = {
|
||||
val validItemQuery =
|
||||
if (settings.deleted) q.withFix(_.andQuery(ItemQuery.Expr.Trashed))
|
||||
else q.withFix(_.andQuery(ItemQuery.Expr.ValidItemStates))
|
||||
settings.searchMode match {
|
||||
case SearchMode.Trashed => q.withFix(_.andQuery(ItemQuery.Expr.Trashed))
|
||||
case SearchMode.Normal => q.withFix(_.andQuery(ItemQuery.Expr.ValidItemStates))
|
||||
}
|
||||
fulltextQuery match {
|
||||
case Some(ftq) if settings.useFTS =>
|
||||
if (q.isEmpty)
|
||||
|
Reference in New Issue
Block a user