Fix Discover crash on scroll from duplicate grid item keys

Addon catalogs can return overlapping items across paginated skip
offsets, so the discover results list could contain the same
type:id twice. LazyVerticalGrid requires unique keys and crashed
with IllegalArgumentException once a duplicate scrolled into view.
Dedupe results in the coordinator where they're assigned.
This commit is contained in:
KhooLy 2026-07-17 16:03:47 +03:00
parent 83f452da15
commit 61e5b2bd52

View file

@ -94,7 +94,7 @@ internal class HomeHeadlessBrowseCoordinator(
)
)
val state = result.state["discover"] as? Map<*, *>
results.value = decodeList(state?.get("results"), metaListType)
results.value = decodeList<Meta>(state?.get("results"), metaListType).distinctBy { "${it.type}:${it.id}" }
resultSources.value = decodeObject(state?.get("resultSources"), sourceMapType) ?: emptyMap()
} finally {
loading.value = false
@ -118,7 +118,7 @@ internal class HomeHeadlessBrowseCoordinator(
)
)
val state = result.state["discover"] as? Map<*, *>
val updated = decodeList<Meta>(state?.get("results"), metaListType)
val updated = decodeList<Meta>(state?.get("results"), metaListType).distinctBy { "${it.type}:${it.id}" }
val source = HomeCatalogSource(transportUrl, catalogId, contentType, genre)
val sources = resultSources.value.toMutableMap()
updated.forEach { item ->