From d870e0a5312b89033c34a8f9b42950d9ebeb77e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8jberg?= Date: Wed, 2 Oct 2024 15:29:41 -0400 Subject: [PATCH] Add Search.isEmptyResults --- src/Lib/Search.elm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Lib/Search.elm b/src/Lib/Search.elm index 7028857f..f975cef6 100644 --- a/src/Lib/Search.elm +++ b/src/Lib/Search.elm @@ -7,6 +7,7 @@ module Lib.Search exposing , fromResult , hasSubstantialQuery , isEmptyQuery + , isEmptyResults , isSearching , queriesEquals , query @@ -182,6 +183,25 @@ isEmptyQuery = query >> String.isEmpty +isEmptyResults : Search a -> Maybe Bool +isEmptyResults s = + case s of + NotAsked _ -> + Nothing + + Searching _ (Just r) -> + Just (SearchResults.isEmpty r) + + Searching _ Nothing -> + Nothing + + Success _ r -> + Just (SearchResults.isEmpty r) + + Failure _ _ -> + Nothing + + isSearching : Search a -> Bool isSearching search_ = case search_ of