fix: stop server sidebar tile rendering a literal "0" badge#3379
fix: stop server sidebar tile rendering a literal "0" badge#3379jeanfbrito wants to merge 1 commit into
Conversation
The per-server sidebar tile rendered a literal "0" overlay whenever a server's unread badge was the number 0. PR #3369 (restore unread badge on 7.8.0+ servers) made injected.ts emit setBadge(0) explicitly via `setBadge(alertIndicator ?? 0)`, so servers now carry `badge: 0` where they previously carried `undefined`. SideBar/index.tsx maps that to `mentionCount={0}`, and ServerButton guarded the Badge with `{mentionCount && <Badge>...}`. Because `0 && <Badge>` evaluates to `0`, React renders the number as a text node — the stray "0" on the tile. Coerce the guard to a boolean (`!!mentionCount`) so a zero count renders nothing. Add a regression test asserting mentionCount={0} produces no "0" text. The aggregate badge sinks (selectGlobalBadge, tray title, dock) already collapse an all-zero state to undefined, so only the per-server tile was affected and they are left unchanged.
|
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 (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
🧰 Additional context used📓 Path-based instructions (2)**/*.{tsx,ts}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🔇 Additional comments (2)
WalkthroughThe server button mention badge now uses an explicit boolean check, and a test was added to confirm a zero mention count does not render a literal ChangesMention badge rendering
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
What changed
The per-server sidebar tile rendered a literal "0" overlay whenever a server's unread
badgewas the number0.ServerButton.tsxguarded its mention<Badge>with:Because
0 && <Badge>evaluates to0, React renders the number as a text node — the stray "0" on the tile. Coerced the guard to a boolean (!!mentionCount) so a zero count renders nothing.Why it surfaced now
PR #3369 (restore unread badge on Rocket.Chat 7.8.0+ servers) made
injected.tsemitsetBadge(0)explicitly viasetBadge(alertIndicator ?? 0). Servers now carrybadge: 0where they previously carriedundefined.SideBar/index.tsxmaps that tomentionCount={0}, which hit the falsy-number render path.Scope
The aggregate badge sinks (
selectGlobalBadge, tray title, dock) already collapse an all-zero state toundefined, so only the per-server tile was affected — those are left unchanged.Test
Added a regression test asserting
mentionCount={0}renders no "0" text.Summary by CodeRabbit
0count no longer appears as a visible badge.