Skip to content

Commit c9445bb

Browse files
authored
fix(ui-components): clamp UserReactionsView spanCount to avoid empty-list crash (#6476)
UserReactionsView.bindReactionList set GridLayoutManager.spanCount directly from the size of the filtered reaction list. When the filter produces an empty list (e.g. reactions whose user is null, or whose type has no registered drawable in ChatUI.supportedReactions), spanCount = 0 was passed to GridLayoutManager.setSpanCount, which rejects it with IllegalArgumentException("Span count should be at least 1. Provided 0"). Coerce the value to at least 1. spanCount = 1 on an empty RecyclerView is harmless; the modal opens with an empty grid instead of crashing.
1 parent 3ae7d8f commit c9445bb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/reactions/user/internal

stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/reactions/user/internal/UserReactionsView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public class UserReactionsView : FrameLayout {
100100
}
101101
}
102102

103-
gridLayoutManager.spanCount = userReactionItems.size.coerceAtMost(MAX_COLUMNS_COUNT)
103+
gridLayoutManager.spanCount = userReactionItems.size
104+
.coerceAtMost(MAX_COLUMNS_COUNT)
105+
.coerceAtLeast(1)
104106
userReactionsAdapter.submitList(userReactionItems)
105107
}
106108

0 commit comments

Comments
 (0)