Skip to content

Comments

Fix crash in channel files screen caused by duplicate IDs#6132

Merged
VelikovPetar merged 2 commits intodevelopfrom
bug/AND-1045_fix_crash_in_channel_files_list
Feb 5, 2026
Merged

Fix crash in channel files screen caused by duplicate IDs#6132
VelikovPetar merged 2 commits intodevelopfrom
bug/AND-1045_fix_crash_in_channel_files_list

Conversation

@VelikovPetar
Copy link
Contributor

@VelikovPetar VelikovPetar commented Feb 5, 2026

Goal

The channel files screen was crashing due to duplicate item IDs in the list. This happened because the ID was generated using attachment.imagePreviewUrl, which can be null for file attachments, causing a message with 2 file attachments to produce the same ID for 2 items.

Implementation

Changed the unique ID generation for ChannelAttachmentsViewState.Result.Item from using attachment.imagePreviewUrl to attachment.hashCode(). This ensures each attachment gets a unique identifier regardless of whether it has an image preview URL.

🎨 UI Changes

crash-before.mp4
crash-after.mp4

Testing

  1. Open a channel
  2. Send a message with two Audio attachments
  3. Open channel info
  4. Open channel Files
  5. There should be no crash

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed attachment identification in channel view to improve overall attachment handling and display reliability.

@VelikovPetar VelikovPetar added the pr:bug Bug fix label Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.26 MB 0.00 MB 🟢
stream-chat-android-offline 5.48 MB 5.48 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.63 MB 10.63 MB 0.00 MB 🟢
stream-chat-android-compose 12.85 MB 12.85 MB 0.00 MB 🟢

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

@VelikovPetar VelikovPetar marked this pull request as ready for review February 5, 2026 11:09
@VelikovPetar VelikovPetar requested a review from a team as a code owner February 5, 2026 11:09
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

The change modifies the unique identifier generation for attachment items in ChannelAttachmentsViewState, replacing the imagePreviewUrl-based identifier with attachment.hashCode(). This alters how attachment items are uniquely identified without changing the overall data structure or behavior.

Changes

Cohort / File(s) Summary
Attachment ID Construction
stream-chat-android-ui-common/.../ChannelAttachmentsViewState.kt
Modified Item.id to use attachment.hashCode() instead of attachment.imagePreviewUrl for generating unique identifiers. Removed unused imagePreviewUrl import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • andremion
  • gpunto

Poem

🐰 A hash replaced the preview's gleam,
Simpler IDs fulfill the dream,
No more URLs in our ID scheme,
Attachment keys now swift as steam! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing a crash caused by duplicate IDs in the channel files screen.
Description check ✅ Passed The description includes Goal, Implementation, UI Changes with videos, and Testing sections. However, it omits several template sections like Contributor Checklist and Reviewer Checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/AND-1045_fix_crash_in_channel_files_list

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VelikovPetar VelikovPetar merged commit cf38d32 into develop Feb 5, 2026
20 of 21 checks passed
@VelikovPetar VelikovPetar deleted the bug/AND-1045_fix_crash_in_channel_files_list branch February 5, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants