Skip to content

Commit

Permalink
Handle featured posts section crash when featured posts list size cha…
Browse files Browse the repository at this point in the history
…nges
  • Loading branch information
msasikanth committed Apr 11, 2024
1 parent 8472407 commit c6a5717
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,19 @@ internal fun FeaturedSection(
snapAnimationSpec = spring(stiffness = Spring.StiffnessVeryLow)
)
) { page ->
val featuredPost = featuredPosts[page]

FeaturedPostItem(
item = featuredPost,
page = page,
pagerState = pagerState,
onClick = { onItemClick(featuredPost) },
onBookmarkClick = { onPostBookmarkClick(featuredPost) },
onCommentsClick = { onPostCommentsClick(featuredPost.commentsLink!!) },
onSourceClick = { onPostSourceClick(featuredPost.feedLink) },
onTogglePostReadClick = { onTogglePostReadClick(featuredPost.link, featuredPost.read) }
)
val featuredPost = featuredPosts.getOrNull(page)
if (featuredPost != null) {
FeaturedPostItem(
item = featuredPost,
page = page,
pagerState = pagerState,
onClick = { onItemClick(featuredPost) },
onBookmarkClick = { onPostBookmarkClick(featuredPost) },
onCommentsClick = { onPostCommentsClick(featuredPost.commentsLink!!) },
onSourceClick = { onPostSourceClick(featuredPost.feedLink) },
onTogglePostReadClick = { onTogglePostReadClick(featuredPost.link, featuredPost.read) }
)
}
}
}
}
Expand Down

0 comments on commit c6a5717

Please sign in to comment.