From a971dbd5d2286a388cb752697bb5fa2cad9506b0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 26 Jun 2024 14:36:01 +0200 Subject: [PATCH] Check last entry Signed-off-by: alperozturk --- .../android/ui/unifiedsearch/UnifiedSearchViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt b/app/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt index d8a363f926..10f0239c02 100644 --- a/app/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt +++ b/app/src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt @@ -43,7 +43,6 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic null } } - fun name(): String? = results.lastOrNull()?.name } @@ -197,11 +196,13 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic searchResults.value = results .filter { it.value.results.isNotEmpty() } .map { (key, value) -> + val isLastEntryHaveValue = results[key]?.results?.last()?.entries?.isEmpty() != true + UnifiedSearchSection( providerID = key, name = value.name()!!, entries = value.results.flatMap { it.entries }, - hasMoreResults = results.isNotEmpty() && results[key]?.nextCursor() != null + hasMoreResults = isLastEntryHaveValue && results[key]?.nextCursor() != null ) } .sortedWith { o1, o2 ->