Potentially fix library IndexOutOfBound crash (#2341)

(cherry picked from commit c4407eda0eed5a7faed47d4470d79e6b1512b5c2)
This commit is contained in:
AntsyLich
2025-08-03 22:53:19 +05:45
committed by NGB-Was-Taken
parent 054de1cc6f
commit 3ac5dcd66e
3 changed files with 46 additions and 26 deletions
@@ -31,7 +31,7 @@ fun LibraryContent(
searchQuery: String?,
selection: Set<Long>,
contentPadding: PaddingValues,
currentPage: () -> Int,
currentPage: Int,
hasActiveFilters: Boolean,
showPageTabs: Boolean,
onChangeCurrentPage: (Int) -> Unit,
@@ -53,8 +53,7 @@ fun LibraryContent(
end = contentPadding.calculateEndPadding(LocalLayoutDirection.current),
),
) {
// SY -->
val coercedCurrentPage = remember(categories) { currentPage().coerceIn(0, categories.lastIndex) }
val coercedCurrentPage = remember(categories, currentPage) { currentPage.coerceIn(0, categories.lastIndex) }
// SY <--
val pagerState = rememberPagerState(coercedCurrentPage) { categories.size }