mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Guard against navigating to a non-existant tab (#629)
Just make sure we don't crash if the selectedTabIndex isn't a positive int. Fixes #628. --------- Co-authored-by: Damontecres <damontecres@gmail.com>
This commit is contained in:
parent
9345d0a698
commit
3d4b06db44
2 changed files with 8 additions and 3 deletions
|
|
@ -51,7 +51,9 @@ fun TabRow(
|
|||
) {
|
||||
val state = rememberLazyListState()
|
||||
LaunchedEffect(selectedTabIndex) {
|
||||
state.animateScrollToItem(selectedTabIndex, -(state.layoutInfo.viewportSize.width / 3.5).toInt())
|
||||
if (selectedTabIndex >= 0) {
|
||||
state.animateScrollToItem(selectedTabIndex, -(state.layoutInfo.viewportSize.width / 3.5).toInt())
|
||||
}
|
||||
}
|
||||
val focusRequesters = remember(tabs) { List(tabs.size) { FocusRequester() } }
|
||||
var rowHasFocus by remember { mutableStateOf(false) }
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class SeriesViewModel
|
|||
} ?: 0
|
||||
Timber.v("Got initial season index: $index")
|
||||
position.update {
|
||||
it.copy(seasonTabIndex = index)
|
||||
it.copy(seasonTabIndex = index.coerceAtLeast(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -547,7 +547,10 @@ private suspend fun findIndexOf(
|
|||
val index =
|
||||
if (targetId != null && (targetNum == null || targetNum !in pager.indices)) {
|
||||
// No hint info, so have to check everything
|
||||
pager.indexOfBlocking { equalsNotNull(it?.id, targetId) }
|
||||
pager.indexOfBlocking {
|
||||
equalsNotNull(it?.indexNumber, targetNum) ||
|
||||
equalsNotNull(it?.id, targetId)
|
||||
}
|
||||
} else if (targetNum != null && targetNum in pager.indices) {
|
||||
// Start searching from the season number and choose direction from there
|
||||
val num = pager.getBlocking(targetNum)?.indexNumber
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue