Skip to content

Commit

Permalink
Merge pull request #2914 from Isira-Seneviratne/take
Browse files Browse the repository at this point in the history
Use take() extension.
  • Loading branch information
Bnyro authored Jan 30, 2023
2 parents 3e6fb49 + 02d9aa5 commit a293480
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.github.libretube.ui.adapters.PlaylistBookmarkAdapter
import com.github.libretube.ui.adapters.PlaylistsAdapter
import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.ui.extensions.withMaxSize
import com.github.libretube.util.LocaleHelper
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -73,7 +72,7 @@ class HomeFragment : BaseFragment() {

private suspend fun fetchHome() {
runOrError {
val feed = SubscriptionHelper.getFeed().withMaxSize(20)
val feed = SubscriptionHelper.getFeed().take(20)
if (feed.isEmpty()) return@runOrError
runOnUiThread {
makeVisible(binding.featuredRV, binding.featuredTV)
Expand All @@ -90,9 +89,8 @@ class HomeFragment : BaseFragment() {
}

runOrError {
val trending = RetrofitInstance.api.getTrending(
LocaleHelper.getTrendingRegion(requireContext())
).withMaxSize(10)
val region = LocaleHelper.getTrendingRegion(requireContext())
val trending = RetrofitInstance.api.getTrending(region).take(10)
if (trending.isEmpty()) return@runOrError
runOnUiThread {
makeVisible(binding.trendingRV, binding.trendingTV)
Expand All @@ -105,7 +103,7 @@ class HomeFragment : BaseFragment() {
}

runOrError {
val playlists = PlaylistsHelper.getPlaylists().withMaxSize(20)
val playlists = PlaylistsHelper.getPlaylists().take(20)
if (playlists.isEmpty()) return@runOrError
runOnUiThread {
makeVisible(binding.playlistsRV, binding.playlistsTV)
Expand Down

0 comments on commit a293480

Please sign in to comment.