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 ->