From bd0540df725959bab8532a851168964541d1c970 Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Sat, 18 Apr 2026 22:34:35 +0530 Subject: [PATCH] fix: stream section key --- .../app/features/streams/StreamsScreen.kt | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt index ff6311e2..3e9ce53a 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamsScreen.kt @@ -745,8 +745,9 @@ internal fun StreamList( } else -> { - filteredGroups.forEach { group -> + filteredGroups.forEachIndexed { groupIndex, group -> streamSection( + sectionKey = streamSectionRenderKey(groupIndex = groupIndex, group = group), group = group, showHeader = uiState.selectedFilter == null, onStreamSelected = onStreamSelected, @@ -769,6 +770,7 @@ internal fun StreamList( } private fun LazyListScope.streamSection( + sectionKey: String, group: AddonStreamGroup, showHeader: Boolean, onStreamSelected: (stream: StreamItem, resumePositionMs: Long?, resumeProgressFraction: Float?) -> Unit, @@ -779,7 +781,7 @@ private fun LazyListScope.streamSection( if (group.streams.isEmpty() && !group.isLoading) return if (showHeader) { - item(key = "header_${group.addonId}") { + item(key = "header_$sectionKey") { StreamSectionHeader( addonName = group.addonName, isLoading = group.isLoading, @@ -793,10 +795,10 @@ private fun LazyListScope.streamSection( val sortedSources = streamsBySource.keys.sortedBy { it.lowercase() } val showSourceHeaders = sortedSources.size > 1 - sortedSources.forEach { sourceName -> + sortedSources.forEachIndexed { sourceIndex, sourceName -> val sourceStreams = streamsBySource[sourceName].orEmpty() if (showSourceHeaders) { - item(key = "source_${group.addonId}_${sourceName}") { + item(key = "source_${sectionKey}_$sourceIndex") { StreamSourceHeader(sourceName = sourceName) } } @@ -804,7 +806,12 @@ private fun LazyListScope.streamSection( itemsIndexed( items = sourceStreams, key = { index, stream -> - "${group.addonId}_${sourceName}_${index}_${stream.url ?: stream.infoHash ?: stream.streamLabel}" + streamCardRenderKey( + sectionKey = sectionKey, + sourceIndex = sourceIndex, + itemIndex = index, + stream = stream, + ) }, ) { _, stream -> StreamCard( @@ -825,6 +832,26 @@ private fun LazyListScope.streamSection( } } +internal fun streamSectionRenderKey( + groupIndex: Int, + group: AddonStreamGroup, +): String = "$groupIndex:${group.addonId}" + +internal fun streamCardRenderKey( + sectionKey: String, + sourceIndex: Int, + itemIndex: Int, + stream: StreamItem, +): String = buildString { + append(sectionKey) + append(':') + append(sourceIndex) + append(':') + append(itemIndex) + append(':') + append(stream.url ?: stream.infoHash ?: stream.streamLabel) +} + // --------------------------------------------------------------------------- // Stream Section Header // ---------------------------------------------------------------------------