Repository: android/compose-samples
File: Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt (Kotlin)

Code before:
    }
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun HomeContent(
    featuredPodcasts: PersistentList<PodcastWithExtraInfo>,
    isRefreshing: Boolean,
    selectedHomeCategory: HomeCategory,
    homeCategories: List<HomeCategory>,
    filterableCategoriesModel: FilterableCategoriesModel,
    podcastCategoryFilterResult: PodcastCategoryFilterResult,
    libraryEpisodes: List<EpisodeToPodcast>,
    scrimColor: Color,
    modifier: Modifier = Modifier,
    onPodcastUnfollowed: (String) -> Unit,
    onHomeCategorySelected: (HomeCategory) -> Unit,
    onCategorySelected: (Category) -> Unit,
    navigateToPlayer: (String) -> Unit,
    onTogglePodcastFollowed: (String) -> Unit,
    onLibraryPodcastSelected: (Podcast?) -> Unit
) {
    val pagerState = rememberPagerState { featuredPodcasts.size }
    LaunchedEffect(pagerState.currentPage, featuredPodcasts) {
        val podcast = featuredPodcasts.getOrNull(pagerState.currentPage)
        onLibraryPodcastSelected(podcast?.podcast)
    }
    LazyColumn(modifier = modifier.fillMaxSize()) {
        if (featuredPodcasts.isNotEmpty()) {
            item {
                FollowedPodcastItem(
                    pagerState = pagerState,
                    items = featuredPodcasts,
                    onPodcastUnfollowed = onPodcastUnfollowed,
                    modifier = Modifier
                        .fillMaxWidth()
                        .verticalGradientScrim(
                            color = scrimColor,
                            startYPercentage = 1f,
                            endYPercentage = 0f
                        )
                )
            }
        }

        if (isRefreshing) {
            // TODO show a progress indicator or similar
        }

        if (featuredPodcasts.isNotEmpty() && homeCategories.isNotEmpty()) {
            stickyHeader {

Review comment (suggestion):
```suggestion
LaunchedEffect(pagerState, featuredPodcasts) {
        snapshotFlow { pagerState.currentPage }
            .collect {
                val podcast = featuredPodcasts.getOrNull(pagerState.currentPage)
                onLibraryPodcastSelected(podcast?.podcast)
            }
    }
```

Code after:
@Composable
private fun HomeContent(
    featuredPodcasts: PersistentList<PodcastWithExtraInfo>,
    isRefreshing: Boolean,
    selectedHomeCategory: HomeCategory,
    homeCategories: List<HomeCategory>,
    filterableCategoriesModel: FilterableCategoriesModel,
    podcastCategoryFilterResult: PodcastCategoryFilterResult,
    libraryEpisodes: List<EpisodeToPodcast>,
    scrimColor: Color,
    modifier: Modifier = Modifier,
    onPodcastUnfollowed: (String) -> Unit,
    onHomeCategorySelected: (HomeCategory) -> Unit,
    onCategorySelected: (Category) -> Unit,
    navigateToPlayer: (String) -> Unit,
    onTogglePodcastFollowed: (String) -> Unit,
    onLibraryPodcastSelected: (Podcast?) -> Unit
) {
    val pagerState = rememberPagerState { featuredPodcasts.size }
    LaunchedEffect(pagerState, featuredPodcasts) {
        snapshotFlow { pagerState.currentPage }
            .collect {
                val podcast = featuredPodcasts.getOrNull(pagerState.currentPage)
                onLibraryPodcastSelected(podcast?.podcast)
            }
    }
    LazyColumn(modifier = modifier.fillMaxSize()) {
        if (featuredPodcasts.isNotEmpty()) {
            item {
                FollowedPodcastItem(
                    pagerState = pagerState,
                    items = featuredPodcasts,
                    onPodcastUnfollowed = onPodcastUnfollowed,
                    modifier = Modifier
                        .fillMaxWidth()
                        .verticalGradientScrim(
                            color = scrimColor,
                            startYPercentage = 1f,
                            endYPercentage = 0f
                        )
                )
            }
        }

        if (isRefreshing) {
            // TODO show a progress indicator or similar
        }

        if (featuredPodcasts.isNotEmpty() && homeCategories.isNotEmpty()) {
            stickyHeader {
                HomeCategoryTabs(