From 8de327db6284460b86638cddcfb4a5162e6150b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Muller?= Date: Thu, 2 Nov 2023 11:17:34 +0100 Subject: [PATCH] Only display "No result" in the `NotLoading` state --- .../pillarbox/demo/ui/integrationLayer/SearchView.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt index 6ba109866..0e8615843 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/integrationLayer/SearchView.kt @@ -107,6 +107,10 @@ private fun SearchResultList( buClicked: (Bu) -> Unit, modifier: Modifier = Modifier ) { + val hasNoResult = lazyPagingItems.loadState.refresh is LoadState.NotLoading && + lazyPagingItems.itemCount == 1 && + lazyPagingItems[0] is SearchContent.BuSelector + LazyColumn(modifier = modifier) { items(count = lazyPagingItems.itemCount, key = lazyPagingItems.itemKey()) { index -> val item = lazyPagingItems[index] @@ -134,8 +138,7 @@ private fun SearchResultList( } } } - // We didn't receive any results - if (lazyPagingItems.itemCount == 1 && lazyPagingItems[0] is SearchContent.BuSelector) { + if (hasNoResult) { item { NoResult( modifier = Modifier