Merge pull request #1024 from eikek/enhance-search-mode

Enhance search mode to search in all items
This commit is contained in:
mergify[bot]
2021-08-21 13:56:43 +00:00
committed by GitHub
7 changed files with 19 additions and 3 deletions

View File

@ -52,6 +52,9 @@ object ItemState {
val invalidStates: NonEmptyList[ItemState] =
NonEmptyList.of(Premature, Processing)
val validStatesAndDeleted: NonEmptyList[ItemState] =
validStates.append(deleted)
def unsafe(str: String): ItemState =
fromString(str).fold(sys.error, identity)

View File

@ -22,11 +22,13 @@ object SearchMode {
final case object Normal extends SearchMode
final case object Trashed extends SearchMode
final case object All extends SearchMode
def fromString(str: String): Either[String, SearchMode] =
str.toLowerCase match {
case "normal" => Right(Normal)
case "trashed" => Right(Trashed)
case "all" => Right(All)
case _ => Left(s"Invalid search mode: $str")
}