From 55555e7159626827cead51a1c67c0a502cf4a6ff Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 25 Jun 2024 10:58:44 +0200 Subject: [PATCH] Fix Signed-off-by: alperozturk --- .../ui/unifiedsearch/SearchOnProviderTask.kt | 2 +- .../ui/unifiedsearch/UnifiedSearchViewModel.kt | 17 +++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/unifiedsearch/SearchOnProviderTask.kt b/app/src/main/java/com/owncloud/android/ui/unifiedsearch/SearchOnProviderTask.kt index 37ed654348..5cbf6d0b34 100644 --- a/app/src/main/java/com/owncloud/android/ui/unifiedsearch/SearchOnProviderTask.kt +++ b/app/src/main/java/com/owncloud/android/ui/unifiedsearch/SearchOnProviderTask.kt @@ -16,7 +16,7 @@ class SearchOnProviderTask( private val provider: String, private val client: NextcloudClient, private val cursor: Int? = null, - private val limit: Int = 6 + private val limit: Int = 5 ) : () -> SearchOnProviderTask.Result { companion object { private const val TAG = "SearchOnProviderTask" 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 b348290833..2503aafa7c 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 @@ -30,7 +30,6 @@ import javax.inject.Inject class UnifiedSearchViewModel(application: Application) : AndroidViewModel(application), IUnifiedSearchViewModel { companion object { private const val TAG = "UnifiedSearchViewModel" - private const val DEFAULT_LIMIT = 5 private const val FILES_PROVIDER_ID = "files" } @@ -39,17 +38,6 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic ) { fun nextCursor(): Int? = results.lastOrNull()?.cursor?.toInt() fun name(): String? = results.lastOrNull()?.name - fun isFinished(): Boolean { - if (results.isEmpty()) { - return false - } - val lastResult = results.last() - return when { - !lastResult.isPaginated -> true - lastResult.entries.size < DEFAULT_LIMIT -> true - else -> false - } - } } private lateinit var currentAccountProvider: CurrentAccountProvider @@ -62,7 +50,6 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic get() = getApplication().applicationContext private lateinit var repository: IUnifiedSearchRepository - private var loadingStarted: Boolean = false private var results: MutableMap = mutableMapOf() override val isLoading = MutableLiveData(false) @@ -201,11 +188,13 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic searchResults.value = results .filter { it.value.results.isNotEmpty() } .map { (key, value) -> + val hasMoreResults = results.isNotEmpty() && results[key]?.nextCursor() != null + UnifiedSearchSection( providerID = key, name = value.name()!!, entries = value.results.flatMap { it.entries }, - hasMoreResults = !value.isFinished() + hasMoreResults = hasMoreResults ) } .sortedWith { o1, o2 ->