Skip to content

Commit

Permalink
Check last entry
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Jun 26, 2024
1 parent 59e721c commit a971dbd
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class UnifiedSearchViewModel(application: Application) : AndroidViewModel(applic
null
}
}

fun name(): String? = results.lastOrNull()?.name
}

Expand Down Expand Up @@ -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 ->
Expand Down

0 comments on commit a971dbd

Please sign in to comment.