From 7c3131c3d0e505fa740cd11732c047a78822558e Mon Sep 17 00:00:00 2001 From: mike a Date: Tue, 22 Mar 2022 15:01:18 -0700 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/24276: fix history list displaying empty state until refresh --- .../org/mozilla/fenix/library/history/HistoryView.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt index ff034d248d..dbdb172448 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryView.kt @@ -36,12 +36,17 @@ class HistoryView( val historyAdapter = HistoryAdapter(interactor).apply { addLoadStateListener { - adapterItemCount = itemCount - Log.d("hehehaha", "adapterItemCount = $adapterItemCount") + // first call will always have itemCount == 0, but we want to keep adapterItemCount + // as null until we can distinguish an empty list from populated, so updateEmptyState() + // could work correctly + if (itemCount != 0) { + adapterItemCount = itemCount + } if (it.source.refresh is LoadState.NotLoading && it.append.endOfPaginationReached && itemCount < 1 ) { + adapterItemCount = 0 onZeroItemsLoaded.invoke() } }