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"
|
applicationId = "nl.vonas.mediacluster.tv"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 7
|
versionCode = 8
|
||||||
versionName = "0.7.0"
|
versionName = "0.7.1"
|
||||||
buildConfigField("String", "DEFAULT_API_BASE", "\"https://master.vonas.nl\"")
|
buildConfigField("String", "DEFAULT_API_BASE", "\"https://master.vonas.nl\"")
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
|
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,8 @@ private fun MainHub(
|
||||||
var shelfPrefs by remember { mutableStateOf<List<ShelfPref>>(emptyList()) }
|
var shelfPrefs by remember { mutableStateOf<List<ShelfPref>>(emptyList()) }
|
||||||
var movieCatalog by remember { mutableStateOf("movies") }
|
var movieCatalog by remember { mutableStateOf("movies") }
|
||||||
var seriesCatalog by remember { mutableStateOf("series") }
|
var seriesCatalog by remember { mutableStateOf("series") }
|
||||||
|
var movieSubId by remember { mutableStateOf("movies") }
|
||||||
|
var seriesSubId by remember { mutableStateOf("series") }
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
runCatching { shelfPrefs = api.getShelfPrefs().sortedBy { it.sortOrder } }
|
runCatching { shelfPrefs = api.getShelfPrefs().sortedBy { it.sortOrder } }
|
||||||
|
|
@ -206,8 +208,11 @@ private fun MainHub(
|
||||||
add(SubNavItem("movies", "Alles"))
|
add(SubNavItem("movies", "Alles"))
|
||||||
add(SubNavItem("recent-movies", "Recent"))
|
add(SubNavItem("recent-movies", "Recent"))
|
||||||
add(SubNavItem("4k-movies", "4K"))
|
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 ->
|
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"))
|
add(SubNavItem("__search__", "Zoeken"))
|
||||||
}
|
}
|
||||||
|
|
@ -216,8 +221,11 @@ private fun MainHub(
|
||||||
buildList {
|
buildList {
|
||||||
add(SubNavItem("series", "Alles"))
|
add(SubNavItem("series", "Alles"))
|
||||||
add(SubNavItem("recent-series", "Recent"))
|
add(SubNavItem("recent-series", "Recent"))
|
||||||
|
val reserved = setOf("series", "recent-series", "__search__")
|
||||||
shelfPrefs.filter { it.kind.equals("SERIES", true) && it.visible }.forEach { p ->
|
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"))
|
add(SubNavItem("__search__", "Zoeken"))
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +237,8 @@ private fun MainHub(
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
val selectedSubId = when (tab) {
|
val selectedSubId = when (tab) {
|
||||||
MainTab.Movies -> movieCatalog
|
MainTab.Movies -> movieSubId
|
||||||
MainTab.Series -> seriesCatalog
|
MainTab.Series -> seriesSubId
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,8 +266,18 @@ private fun MainHub(
|
||||||
tab = it
|
tab = it
|
||||||
navFocused = true
|
navFocused = true
|
||||||
when (it) {
|
when (it) {
|
||||||
MainTab.Movies -> if (movieCatalog == "__search__") movieCatalog = "movies"
|
MainTab.Movies -> {
|
||||||
MainTab.Series -> if (seriesCatalog == "__search__") seriesCatalog = "series"
|
if (movieSubId == "__search__") {
|
||||||
|
movieSubId = "movies"
|
||||||
|
movieCatalog = "movies"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MainTab.Series -> {
|
||||||
|
if (seriesSubId == "__search__") {
|
||||||
|
seriesSubId = "series"
|
||||||
|
seriesCatalog = "series"
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -271,8 +289,14 @@ private fun MainHub(
|
||||||
navFocused = true
|
navFocused = true
|
||||||
} else {
|
} else {
|
||||||
when (tab) {
|
when (tab) {
|
||||||
MainTab.Movies -> movieCatalog = item.id
|
MainTab.Movies -> {
|
||||||
MainTab.Series -> seriesCatalog = item.id
|
movieSubId = item.id
|
||||||
|
movieCatalog = item.catalogId
|
||||||
|
}
|
||||||
|
MainTab.Series -> {
|
||||||
|
seriesSubId = item.id
|
||||||
|
seriesCatalog = item.catalogId
|
||||||
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -290,14 +314,14 @@ private fun MainHub(
|
||||||
MainTab.Movies -> BrowseScreen(
|
MainTab.Movies -> BrowseScreen(
|
||||||
api = api,
|
api = api,
|
||||||
catalogId = movieCatalog,
|
catalogId = movieCatalog,
|
||||||
titleHint = movieSubs.firstOrNull { it.id == movieCatalog }?.label ?: "Films",
|
titleHint = movieSubs.firstOrNull { it.id == movieSubId }?.label ?: "Films",
|
||||||
onOpenMovie = onOpenMovie,
|
onOpenMovie = onOpenMovie,
|
||||||
onOpenSeries = onOpenSeries,
|
onOpenSeries = onOpenSeries,
|
||||||
)
|
)
|
||||||
MainTab.Series -> BrowseScreen(
|
MainTab.Series -> BrowseScreen(
|
||||||
api = api,
|
api = api,
|
||||||
catalogId = seriesCatalog,
|
catalogId = seriesCatalog,
|
||||||
titleHint = seriesSubs.firstOrNull { it.id == seriesCatalog }?.label ?: "Series",
|
titleHint = seriesSubs.firstOrNull { it.id == seriesSubId }?.label ?: "Series",
|
||||||
onOpenMovie = onOpenMovie,
|
onOpenMovie = onOpenMovie,
|
||||||
onOpenSeries = onOpenSeries,
|
onOpenSeries = onOpenSeries,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ enum class MainTab(val label: String) {
|
||||||
data class SubNavItem(
|
data class SubNavItem(
|
||||||
val id: String,
|
val id: String,
|
||||||
val label: String,
|
val label: String,
|
||||||
|
/** Catalog-id voor de API (kan afwijken van Compose-key `id`). */
|
||||||
|
val catalogId: String = id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@OptIn(ExperimentalTvMaterial3Api::class)
|
@OptIn(ExperimentalTvMaterial3Api::class)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue