From a43bea2c04f9134247c3e8dc78b90b260ec73a05 Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Sun, 14 Dec 2025 17:09:35 +0530 Subject: [PATCH 1/5] Fix duplicate LazyGrid keys in channel media attachments --- .../ui/channel/attachments/ChannelMediaAttachmentsGrid.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt index e66c6a4e067..e0c358c3402 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt @@ -156,14 +156,14 @@ internal fun ChannelMediaAttachmentsGrid( ) { itemsIndexed( items = content.items, - key = { _, item -> item.id }, + key = { index, item -> "${item.id}-$index " }, ) { index, item -> itemContent(index, item) { previewItemIndex = index } } if (content.isLoadingMore) { - item { loadingItem() } + item(key = "loading_item") { loadingItem() } } } From 35ab7650e605f8606fdf1e252af4d780ced45828 Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Tue, 16 Dec 2025 19:12:55 +0530 Subject: [PATCH 2/5] Revert ChannelMediaAttachmentsGrid.kt workaround for duplicate keys --- .../ui/channel/attachments/ChannelMediaAttachmentsGrid.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt index e0c358c3402..e66c6a4e067 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/attachments/ChannelMediaAttachmentsGrid.kt @@ -156,14 +156,14 @@ internal fun ChannelMediaAttachmentsGrid( ) { itemsIndexed( items = content.items, - key = { index, item -> "${item.id}-$index " }, + key = { _, item -> item.id }, ) { index, item -> itemContent(index, item) { previewItemIndex = index } } if (content.isLoadingMore) { - item(key = "loading_item") { loadingItem() } + item { loadingItem() } } } From acc225be480f1a295dff2dd66838de4547ee303a Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Tue, 16 Dec 2025 20:29:09 +0530 Subject: [PATCH 3/5] Fix attachment item id to avoid duplicate LazyGrid keys --- .../state/channel/attachments/ChannelAttachmentsViewState.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channel/attachments/ChannelAttachmentsViewState.kt b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channel/attachments/ChannelAttachmentsViewState.kt index 33edd89f40a..dea057103f9 100644 --- a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channel/attachments/ChannelAttachmentsViewState.kt +++ b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channel/attachments/ChannelAttachmentsViewState.kt @@ -18,7 +18,6 @@ package io.getstream.chat.android.ui.common.state.channel.attachments import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Message -import io.getstream.chat.android.ui.common.utils.extensions.getDisplayableName import io.getstream.chat.android.ui.common.utils.extensions.imagePreviewUrl /** @@ -61,7 +60,7 @@ public sealed interface ChannelAttachmentsViewState { * Returns the unique identifier for the item. */ public val id: String = - "${message.identifierHash()}-${attachment.getDisplayableName() ?: attachment.imagePreviewUrl}" + "${message.identifierHash()}-${attachment.imagePreviewUrl}" } } From 077f732e3def2fa1624ee7f2ac19f0b0903a9a6e Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Wed, 7 Jan 2026 14:28:27 +0530 Subject: [PATCH 4/5] fix: preview message test data to avoid duplicate attachment URLs --- .../io/getstream/chat/android/previewdata/PreviewMessageData.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/stream-chat-android-previewdata/src/main/kotlin/io/getstream/chat/android/previewdata/PreviewMessageData.kt b/stream-chat-android-previewdata/src/main/kotlin/io/getstream/chat/android/previewdata/PreviewMessageData.kt index 7355e1c443a..b7b194e2877 100644 --- a/stream-chat-android-previewdata/src/main/kotlin/io/getstream/chat/android/previewdata/PreviewMessageData.kt +++ b/stream-chat-android-previewdata/src/main/kotlin/io/getstream/chat/android/previewdata/PreviewMessageData.kt @@ -122,14 +122,12 @@ public object PreviewMessageData { type = "image", mimeType = "image/jpeg", imageUrl = "https://example.com/image1.jpg", - thumbUrl = "https://example.com/thumb1.jpg", ), Attachment( name = "video1.mp4", fileSize = 2000000, type = "video", mimeType = "video/mp4", - imageUrl = "https://example.com/image1.jpg", thumbUrl = "https://example.com/thumb1.jpg", ), ), From e1101d669b0007dd82a02f81a66387fd902b556e Mon Sep 17 00:00:00 2001 From: Ambarish Manna Date: Thu, 8 Jan 2026 13:08:26 +0530 Subject: [PATCH 5/5] fix(test): make share failure test deterministic --- .../channel/ChannelMediaAttachmentsPreviewViewModelTest.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelMediaAttachmentsPreviewViewModelTest.kt b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelMediaAttachmentsPreviewViewModelTest.kt index 6ab98faea2e..165d77bb9f5 100644 --- a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelMediaAttachmentsPreviewViewModelTest.kt +++ b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelMediaAttachmentsPreviewViewModelTest.kt @@ -254,6 +254,9 @@ internal class ChannelMediaAttachmentsPreviewViewModelTest { val attachment = randomAttachment( // Less than 10MB fileSize = positiveRandomInt(maxInt = (10 * 1024 * 1024) - 1), + assetUrl = null, + imageUrl = null, + thumbUrl = null, ) val shareError = Error.GenericError(message = randomString()) val sut = Fixture()