Fix Series tab crash from duplicate LazyRow key series.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
cc16761500
commit
8301d5191f
3 changed files with 38 additions and 12 deletions
|
|
@ -12,8 +12,8 @@ android {
|
|||
applicationId = "nl.vonas.mediacluster.tv"
|
||||
minSdk = 24
|
||||
targetSdk = 35
|
||||
versionCode = 7
|
||||
versionName = "0.7.0"
|
||||
versionCode = 8
|
||||
versionName = "0.7.1"
|
||||
buildConfigField("String", "DEFAULT_API_BASE", "\"https://master.vonas.nl\"")
|
||||
ndk {
|
||||
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
|
||||
|
|
|
|||
|
|
@ -196,6 +196,8 @@ private fun MainHub(
|
|||
var shelfPrefs by remember { mutableStateOf<List<ShelfPref>>(emptyList()) }
|
||||
var movieCatalog by remember { mutableStateOf("movies") }
|
||||
var seriesCatalog by remember { mutableStateOf("series") }
|
||||
var movieSubId by remember { mutableStateOf("movies") }
|
||||
var seriesSubId by remember { mutableStateOf("series") }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
runCatching { shelfPrefs = api.getShelfPrefs().sortedBy { it.sortOrder } }
|
||||
|
|
@ -206,8 +208,11 @@ private fun MainHub(
|
|||
add(SubNavItem("movies", "Alles"))
|
||||
add(SubNavItem("recent-movies", "Recent"))
|
||||
add(SubNavItem("4k-movies", "4K"))
|
||||
val reserved = setOf("movies", "recent-movies", "4k-movies", "__search__")
|
||||
shelfPrefs.filter { it.kind.equals("MOVIE", true) && it.visible }.forEach { p ->
|
||||
add(SubNavItem(p.slug.ifBlank { p.shelfId }, p.name))
|
||||
val slug = p.slug.ifBlank { p.shelfId }
|
||||
val catalog = if (slug in reserved) p.shelfId else slug
|
||||
add(SubNavItem(id = "shelf-${p.shelfId}", label = p.name, catalogId = catalog))
|
||||
}
|
||||
add(SubNavItem("__search__", "Zoeken"))
|
||||
}
|
||||
|
|
@ -216,8 +221,11 @@ private fun MainHub(
|
|||
buildList {
|
||||
add(SubNavItem("series", "Alles"))
|
||||
add(SubNavItem("recent-series", "Recent"))
|
||||
val reserved = setOf("series", "recent-series", "__search__")
|
||||
shelfPrefs.filter { it.kind.equals("SERIES", true) && it.visible }.forEach { p ->
|
||||
add(SubNavItem(p.slug.ifBlank { p.shelfId }, p.name))
|
||||
val slug = p.slug.ifBlank { p.shelfId }
|
||||
val catalog = if (slug in reserved) p.shelfId else slug
|
||||
add(SubNavItem(id = "shelf-${p.shelfId}", label = p.name, catalogId = catalog))
|
||||
}
|
||||
add(SubNavItem("__search__", "Zoeken"))
|
||||
}
|
||||
|
|
@ -229,8 +237,8 @@ private fun MainHub(
|
|||
else -> emptyList()
|
||||
}
|
||||
val selectedSubId = when (tab) {
|
||||
MainTab.Movies -> movieCatalog
|
||||
MainTab.Series -> seriesCatalog
|
||||
MainTab.Movies -> movieSubId
|
||||
MainTab.Series -> seriesSubId
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
|
@ -258,8 +266,18 @@ private fun MainHub(
|
|||
tab = it
|
||||
navFocused = true
|
||||
when (it) {
|
||||
MainTab.Movies -> if (movieCatalog == "__search__") movieCatalog = "movies"
|
||||
MainTab.Series -> if (seriesCatalog == "__search__") seriesCatalog = "series"
|
||||
MainTab.Movies -> {
|
||||
if (movieSubId == "__search__") {
|
||||
movieSubId = "movies"
|
||||
movieCatalog = "movies"
|
||||
}
|
||||
}
|
||||
MainTab.Series -> {
|
||||
if (seriesSubId == "__search__") {
|
||||
seriesSubId = "series"
|
||||
seriesCatalog = "series"
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
},
|
||||
|
|
@ -271,8 +289,14 @@ private fun MainHub(
|
|||
navFocused = true
|
||||
} else {
|
||||
when (tab) {
|
||||
MainTab.Movies -> movieCatalog = item.id
|
||||
MainTab.Series -> seriesCatalog = item.id
|
||||
MainTab.Movies -> {
|
||||
movieSubId = item.id
|
||||
movieCatalog = item.catalogId
|
||||
}
|
||||
MainTab.Series -> {
|
||||
seriesSubId = item.id
|
||||
seriesCatalog = item.catalogId
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
|
@ -290,14 +314,14 @@ private fun MainHub(
|
|||
MainTab.Movies -> BrowseScreen(
|
||||
api = api,
|
||||
catalogId = movieCatalog,
|
||||
titleHint = movieSubs.firstOrNull { it.id == movieCatalog }?.label ?: "Films",
|
||||
titleHint = movieSubs.firstOrNull { it.id == movieSubId }?.label ?: "Films",
|
||||
onOpenMovie = onOpenMovie,
|
||||
onOpenSeries = onOpenSeries,
|
||||
)
|
||||
MainTab.Series -> BrowseScreen(
|
||||
api = api,
|
||||
catalogId = seriesCatalog,
|
||||
titleHint = seriesSubs.firstOrNull { it.id == seriesCatalog }?.label ?: "Series",
|
||||
titleHint = seriesSubs.firstOrNull { it.id == seriesSubId }?.label ?: "Series",
|
||||
onOpenMovie = onOpenMovie,
|
||||
onOpenSeries = onOpenSeries,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ enum class MainTab(val label: String) {
|
|||
data class SubNavItem(
|
||||
val id: String,
|
||||
val label: String,
|
||||
/** Catalog-id voor de API (kan afwijken van Compose-key `id`). */
|
||||
val catalogId: String = id,
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalTvMaterial3Api::class)
|
||||
|
|
|
|||
Loading…
Reference in a new issue