Repository navigation
fix(core): show an empty message preview when there is nothing to describe - #3826
Merged
Merged
Conversation
…cribe A message or draft with no text and no attachments fell through to the attachment wording in useMessagePreviewText: an absent `attachments` rendered "0 Files", and an empty array matched `onlyAudio` (0 === 0) and rendered "0 Audios". Return an empty preview instead, matching useMessagePreviewIcon, which already returns null in that case. Refs RN-432
Contributor
SDK Size
|
3 of 6 tasks
szuperaz
approved these changes
Sep 25, 2026
szuperaz
left a comment
Contributor
There was a problem hiding this comment.
I think we may have a discrepancy in the SDK, because I can create an empty draft using Oliver's repro steps:
- Quote a message
- Don't type/upload anything
That way I can see the issue on "Drafts" tab, but not in channel preivew, but that has nothing to do with the fix, just something I noticed.
isekovanic
approved these changes
Sep 25, 2026
oliverlaz
added a commit
that referenced
this pull request
Sep 25, 2026
…cribe (#3827) ## 🎯 Goal A message or draft with no text and no attachments rendered a bogus attachment summary as its preview. It showed up in the SampleApp Drafts list as a literal `{{count}} Files` during the iPhone Duo device pass (RN-429). The same hook also feeds the channel-list last-message preview, the thread list, the reply preview and the SampleApp Reminders list. The easiest way to hit it: in a channel, long-press a message → **Reply**, type nothing, and go back. `stream-chat` saves a draft that has only a `quoted_message_id`, so the Drafts tab shows `{{count}} Files`. Linear: [RN-432](https://linear.app/stream/issue/RN-432/message-preview-shows-0-files-0-audios-for-messages-with-nothing-to) · Same fix on `V10`: #3826 ## 🛠 Implementation details `useMessagePreviewText` had no exit for "nothing to describe", so it fell through to its attachment wording: | `message.attachments` | before | after | | --- | --- | --- | | absent | literal `{{count}} Files`: `count` is undefined, so no `_one`/`_other` key matches | `''` | | `[]` | "0 Audios": `onlyAudio` is `0 === 0` | `''` | It now returns an empty preview once the text check has passed and there are no attachments. The sibling `useMessagePreviewIcon` already returns `null` in that case, and it guards `onlyAudio` with `audios?.length &&` for exactly this reason. Deleted messages, polls, locations, giphys and text all return before the new check, so they are unaffected. Mixed attachments still read "N Files". ## 🎨 UI Changes The rows that showed `{{count}} Files` or "0 Audios" now show an empty subtitle, the same as their icon, which was already absent. No other visual change. ## 🧪 Testing New `package/src/hooks/messagePreview/__tests__/useMessagePreviewText.test.tsx`: - **Regression:** an absent `attachments` and an empty one both return `''`. Both failed before the fix. - **Unchanged behaviour:** mixed attachments give "2 Files", audio-only gives "2 Audios", and text wins over attachments. The counted cases use `waitFor`, because translations load asynchronously in tests. | Gate | Result | | --- | --- | | `yarn lint` | exit 0 | | `cd package && yarn test:typecheck` | exit 0 | | `yarn build` | succeeds | | `yarn test:unit` | 186 suites, 1511 passed (14 skipped), 12 snapshots | Not checked in the running app. The change is covered by the hook tests. ## ☑️ Checklist - [x] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [x] PR targets the `develop` branch - [x] Documentation is updated — not needed, no API change - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
Contributor
|
🎉 This PR is included in version 10.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Goal
A message or draft with no text and no attachments rendered a bogus attachment summary as its preview. It showed up in the SampleApp Drafts list during the iPhone Duo device pass (RN-429), and the same hook also feeds the channel-list last-message preview, the thread list, the reply preview and the SampleApp Reminders list.
Linear: RN-432 · Same fix on
develop: #3827🛠 Implementation details
useMessagePreviewTexthad no exit for "nothing to describe", so it fell through to its attachment wording:message.attachments''[]onlyAudiois0 === 0''It now returns an empty preview once the text check has passed and there are no attachments. The sibling
useMessagePreviewIconalready returnsnullin that case, and it guardsonlyAudiowithaudios?.length &&for exactly this reason. The early return also makes the fall-through'scount: attachmentsLength ?? 0workaround unnecessary: that workaround had only turned develop's literal{{count}} Filesinto "0 Files".Deleted messages, polls, locations, giphys and text all return before the new check, so they are unaffected. Mixed attachments still read "N Files".
🎨 UI Changes
The rows that showed "0 Files" or "0 Audios" now show an empty subtitle, the same as their icon, which was already absent. No other visual change.
🧪 Testing
New
package/src/hooks/messagePreview/__tests__/useMessagePreviewText.test.tsx:attachmentsand an empty one both return''. Before the fix these two cases failed with exactly"0 Files"and"0 Audios".yarn lintcd package && yarn test:typecheckyarn buildsrc/i18n/keys.tsunchangedyarn test:unitMessageList pagination › scroll to bottom button, which the test file marks as flaky (~20% of runs, pre-existing on V10). It passed 3/3 both with and without this change.Not checked in the running app. The change is covered by the hook tests.
☑️ Checklist
developbranch — targetsV10; thedevelopfix is fix(core): show an empty message preview when there is nothing to describe #3827