From cfc903403ab287c0ba62405b0ef3b049de708e22 Mon Sep 17 00:00:00 2001 From: eikek Date: Fri, 3 Jun 2022 00:20:02 +0200 Subject: [PATCH] Fix load-more button state --- modules/webapp/src/main/elm/Data/Items.elm | 12 ++++++++++++ modules/webapp/src/main/elm/Page/Search/Update.elm | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/webapp/src/main/elm/Data/Items.elm b/modules/webapp/src/main/elm/Data/Items.elm index 0cf52354..cddeb78a 100644 --- a/modules/webapp/src/main/elm/Data/Items.elm +++ b/modules/webapp/src/main/elm/Data/Items.elm @@ -10,7 +10,9 @@ module Data.Items exposing , first , flatten , idSet + , isEmpty , length + , nonEmpty , replaceIn , unwrapGroups ) @@ -23,6 +25,16 @@ import Set exposing (Set) import Util.List +isEmpty : ItemLightList -> Bool +isEmpty list = + List.all (.items >> List.isEmpty) list.groups + + +nonEmpty : ItemLightList -> Bool +nonEmpty list = + not (isEmpty list) + + flatten : ItemLightList -> List ItemLight flatten list = List.concatMap .items list.groups diff --git a/modules/webapp/src/main/elm/Page/Search/Update.elm b/modules/webapp/src/main/elm/Page/Search/Update.elm index 6816d479..5a1afa04 100644 --- a/modules/webapp/src/main/elm/Page/Search/Update.elm +++ b/modules/webapp/src/main/elm/Page/Search/Update.elm @@ -209,7 +209,7 @@ update texts bookmarkId lastViewedItemId env msg model = { model | searchInProgress = False , searchOffset = noff - , moreAvailable = list.groups /= [] + , moreAvailable = Data.Items.nonEmpty list } in makeResult env.selectedItems <| @@ -233,7 +233,7 @@ update texts bookmarkId lastViewedItemId env msg model = | searchInProgress = False , moreInProgress = False , searchOffset = noff - , moreAvailable = list.groups /= [] + , moreAvailable = Data.Items.nonEmpty list } in update texts bookmarkId lastViewedItemId env (ItemCardListMsg (Comp.ItemCardList.AddResults list)) m