Fix reactions modal crash when no reactions can be displayed#6475
Conversation
…list crash
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.
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR fixes a layout edge case in the user reactions view by enforcing valid grid span count boundaries. The reaction grid's layout manager now clamps column count to a minimum of 1 and maximum of MAX_COLUMNS_COUNT, preventing invalid state when no reactions are displayed. ChangesUser Reactions Grid Layout
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SDK Size Comparison 📏
|
|
|
🚀 Available in v6.39.0 |



Closes AND-1194
Goal
Fix the
IllegalArgumentException: Span count should be at least 1. Provided 0crash fromUserReactionsView.bindReactionListwhen the reactions modal opens on a message whose filteredlatestReactionsends up empty.Implementation
UserReactionsView.bindReactionListsetgridLayoutManager.spanCountdirectly from the size of the filtered reaction list:When
userReactionItemsis empty — every reaction hasuser == null, orChatUI.supportedReactions.getReactionDrawable(type) == null, orlatestReactionsitself is empty whilereactionGroupsis populated —spanCount = 0is passed toGridLayoutManager.setSpanCount, which rejects it.Clamp the value to at least 1:
spanCount = 1on an emptyRecyclerViewis harmless — the grid has no rows regardless of the span count. The modal opens with its title ("0 reactions") and an empty grid instead of crashing../gradlew apiDumpproduced zero.apidiff, confirming no public surface change.Testing
Manual repro needs a small sample-app patch — applied to
ComponentBrowserUserReactionsFragmentand its layout — that adds a tap target which callsUserReactionsView.setMessagewithlatestReactions = emptyList(). Apply the patch below, then:stream-chat-android-ui-components-sample. On the user picker, tap the SDK Version label at the bottom to open the Component Browser.UserReactionsView.kt:103with the exact stack trace reported by the customer.Also verified:
./gradlew spotlessApply detekt apiDump— clean../gradlew :stream-chat-android-ui-components:testDebugUnitTest— green.Sample-app patch for manual verification
Summary by CodeRabbit