fix: ReactionsList showing empty when a user reacts to a message#7204
fix: ReactionsList showing empty when a user reacts to a message#7204divyanshu-patil wants to merge 3 commits intoRocketChat:developfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (4)**/*.{js,jsx,ts,tsx,json}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📓 Common learnings🔇 Additional comments (1)
WalkthroughNormalize reaction Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/lib/methods/helpers/normalizeMessage.ts`:
- Line 44: In normalizeMessage.ts the reactions block currently sets names with
msg.reactions[key].names || [] which misses sparse/empty entries; update it so
you iterate over (msg.reactions[key].names || []) and replace any falsy/missing
entry with a safe fallback (e.g., empty string or a default username) per entry
before assigning to names, ensuring each reaction name is a non-empty string;
locate the reactions usage in the normalizeMessage function and apply this
per-entry mapping to msg.reactions[key].names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dfd300c7-5c4e-4fec-a574-df01e1274ec5
📒 Files selected for processing (1)
app/lib/methods/helpers/normalizeMessage.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Configure Prettier with tabs, single quotes, 130 character width, no trailing commas, arrow parens avoid, and bracket same line
Files:
app/lib/methods/helpers/normalizeMessage.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use ESLint with
@rocket.chat/eslint-configbase configuration including React, React Native, TypeScript, and Jest plugins
Files:
app/lib/methods/helpers/normalizeMessage.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use TypeScript with strict mode enabled and configure baseUrl to app/ for import resolution
**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers
Files:
app/lib/methods/helpers/normalizeMessage.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions
Files:
app/lib/methods/helpers/normalizeMessage.ts
Proposed changes
On the client side, the reactions bottom sheet was directly reading from
reaction.namesto display user names. WhenUI_Use_Real_Nameis disabled or names are not present in the payload,reaction.namescould be undefined or sparse, causing the display to show blank entries instead of falling back to usernames.This PR adds a fallback so that when
reaction.names[i]is empty or not present, the component falls back toreaction.usernames[i]instead.Issue(s)
Related to the server-side fix that was not sending names in payload even when
UI_Use_Real_Namewas true. This client-side change acts as a defensive fallback for cases where names are unavailable.Related Pull request: RocketChat/Rocket.Chat#40254
How to test or reproduce
Before: user entries appear blank when
reaction.namesis empty or sparseAfter: falls back to displaying usernames when names are not available
Screenshots
Before
before.reactions.mp4
After
after.reactions.mp4
Types of changes
Checklist
Further comments
This is a companion to the server-side PR that populates
reaction.namesingetMessageToBroadcast. Even with that fix in place, this client-side fallback (reaction.names?.[i] || reaction.usernames[i]) is valuable as a defensive measure — for example, for older cached messages or servers that haven't yet deployed the server-side fix.Summary by CodeRabbit