fix(core): show an empty message preview when there is nothing to describe - #3827
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 a literal "{{count}} 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
2 of 6 tasks
Contributor
SDK Size
|
szuperaz
approved these changes
Sep 25, 2026
isekovanic
approved these changes
Sep 25, 2026
oliverlaz
added a commit
that referenced
this pull request
Sep 25, 2026
…cribe (#3826) ## 🎯 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](https://linear.app/stream/issue/RN-432/message-preview-shows-0-files-0-audios-for-messages-with-nothing-to) · Same fix on `develop`: #3827 ## 🛠 Implementation details `useMessagePreviewText` had no exit for "nothing to describe", so it fell through to its attachment wording: | `message.attachments` | before | after | | --- | --- | --- | | absent | "0 Files" | `''` | | `[]` | "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. The early return also makes the fall-through's `count: attachmentsLength ?? 0` workaround unnecessary: that workaround had only turned develop's literal `{{count}} Files` into "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`: - **Regression:** an absent `attachments` and an empty one both return `''`. Before the fix these two cases failed with exactly `"0 Files"` and `"0 Audios"`. - **Unchanged behaviour:** mixed attachments give "2 Files", audio-only gives "2 Audios", and text wins over attachments. | Gate | Result | | --- | --- | | `yarn lint` | exit 0 | | `cd package && yarn test:typecheck` | exit 0 | | `yarn build` | succeeds; `src/i18n/keys.ts` unchanged | | `yarn test:unit` | 2010 passed, 13 skipped, 1 failed. The failure is `MessageList 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 - [x] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch — targets `V10`; the `develop` fix is #3827 - [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 9.9.2 🎉 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 as a literal
{{count}} Filesduring 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-chatsaves a draft that has only aquoted_message_id, so the Drafts tab shows{{count}} Files.Linear: RN-432 · Same fix on
V10: #3826🛠 Implementation details
useMessagePreviewTexthad no exit for "nothing to describe", so it fell through to its attachment wording:message.attachments{{count}} Files:countis undefined, so no_one/_otherkey matches''[]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.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}} Filesor "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''. Both failed before the fix.waitFor, because translations load asynchronously in tests.yarn lintcd package && yarn test:typecheckyarn buildyarn test:unitNot checked in the running app. The change is covered by the hook tests.
☑️ Checklist
developbranch