Display the "Unsupported attachment" in the message composer#6256
Display the "Unsupported attachment" in the message composer#6256
Conversation
…d attachment" string as a fallback when both `attachment.title` and `attachment.name` are null.
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
MessageComposerAttachmentFileItem to display the "Unsupporte…
SDK Size Comparison 📏
|
WalkthroughThe changes improve file attachment display in the message composer by introducing a localized fallback message. Previously, missing attachment metadata resulted in an empty string; now it displays "Unsupported attachment" retrieved from string resources, with a defined fallback hierarchy: attachment.title → attachment.name → localized string. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can disable sequence diagrams in the walkthrough.Disable the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/composer/internal/attachments/MessageComposerAttachmentFileItem.kt (1)
79-81: Consider incorporatingattachment.fallbackin the hierarchy.The
Attachmentmodel has afallbackfield documented as "Fallback text used when [title] and [name] are absent." Other places in the codebase (e.g.,MessagePreviewFormatter) use the patterntitle ?: name ?: fallback ?: "". You might want to checkattachment.fallbackbefore falling back to the localized string, in case the server provides a meaningful fallback value:text = attachment.title ?: attachment.name ?: attachment.fallback ?: stringResource(R.string.stream_compose_message_composer_unsupported_attachment),That said, if the intent is to always show "Unsupported attachment" for files without metadata in the composer context specifically, the current implementation is fine.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/composer/internal/attachments/MessageComposerAttachmentFileItem.kt` around lines 79 - 81, The text selection for the attachment label in MessageComposerAttachmentFileItem should include attachment.fallback before falling back to the localized unsupported message; update the expression used to set text (the assignment that currently uses attachment.title ?: attachment.name ?: stringResource(R.string.stream_compose_message_composer_unsupported_attachment)) to check attachment.fallback (i.e., title ?: name ?: fallback ?: stringResource(...)) so any server-provided fallback is shown when title and name are absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/composer/internal/attachments/MessageComposerAttachmentFileItem.kt`:
- Around line 79-81: The text selection for the attachment label in
MessageComposerAttachmentFileItem should include attachment.fallback before
falling back to the localized unsupported message; update the expression used to
set text (the assignment that currently uses attachment.title ?: attachment.name
?:
stringResource(R.string.stream_compose_message_composer_unsupported_attachment))
to check attachment.fallback (i.e., title ?: name ?: fallback ?:
stringResource(...)) so any server-provided fallback is shown when title and
name are absent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f8fd613c-a4ba-40c7-b357-f25fc80a654d
📒 Files selected for processing (2)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/composer/internal/attachments/MessageComposerAttachmentFileItem.ktstream-chat-android-compose/src/main/res/values/strings.xml
|



Goal
Display the "Unsupported attachment" in the message composer
Implementation
Display the "Unsupported attachment" when a file does not have title nor name
Testing
Summary by CodeRabbit