Coerce current pager page better
This commit is contained in:
parent
a9e2394c6d
commit
8d3888a572
@ -53,7 +53,7 @@ fun LibraryContent(
|
||||
end = contentPadding.calculateEndPadding(LocalLayoutDirection.current),
|
||||
),
|
||||
) {
|
||||
val coercedCurrentPage = remember { currentPage().coerceAtMost(categories.lastIndex) }
|
||||
val coercedCurrentPage = remember { currentPage().coerceIn(0, categories.lastIndex) }
|
||||
val pagerState = rememberPagerState(coercedCurrentPage)
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
@ -79,7 +79,7 @@ fun LibraryContent(
|
||||
PullRefresh(
|
||||
refreshing = isRefreshing,
|
||||
onRefresh = {
|
||||
val started = onRefresh(categories[currentPage()])
|
||||
val started = onRefresh(categories.getOrNull(currentPage()) ?: return@PullRefresh)
|
||||
if (!started) return@PullRefresh
|
||||
scope.launch {
|
||||
// Fake refresh status but hide it after a second as it's a long running task
|
||||
|
Loading…
x
Reference in New Issue
Block a user