refactor: remove unread from Meteor - #36001
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #36001 +/- ##
===========================================
+ Coverage 64.70% 64.72% +0.02%
===========================================
Files 3247 3248 +1
Lines 95434 95463 +29
Branches 17902 17912 +10
===========================================
+ Hits 61753 61791 +38
+ Misses 30778 30770 -8
+ Partials 2903 2902 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
* fix: restore unread badge on Rocket.Chat 7.8.0+ servers The dock/tray/sidebar unread badge stopped appearing on servers running Rocket.Chat 7.8.0 or newer. Server PR RocketChat/Rocket.Chat#36001 ("refactor: remove `unread` from Meteor", first shipped in 7.8.0) deleted `client/startup/unread.ts`, which was the only code writing `Session.set('unread', ...)`. Unread state moved to a React-only store. The desktop app reads the badge exclusively through `Tracker.autorun(() => setBadge(Session.get('unread')))` in injected.ts, so on those servers that Meteor source now resolves to `undefined` forever and the badge clears across every sink. Those servers still broadcast unread state through two global CustomEvents on `window`, mirroring the server's own `useUnread` hook: - `unread-changed`: the aggregate numeric count (recompute trigger). - `unread-changed-by-subscription`: per-subscription { rid, unread, alert, unreadAlert }, accumulated here to rebuild the alert-only "•" indicator. injected.ts now listens to both and resolves the badge with the same logic useUnread uses: positive count wins, otherwise alert-only "•", otherwise no badge. The legacy Session autorun is kept as a fallback for servers older than 7.8.0. Known limitation: `unread-changed-by-subscription` is incremental, so an alert-only room (zero count) that settled before the listener attached may not show its dot until it next changes; any real unread count always shows immediately. * fix: gate legacy badge autorun and use aggregate unread count Address CodeRabbit review on PR #3369: - Gate the legacy Session.get('unread') autorun behind a pre-7.8.0 version check so it no longer fires setBadge(undefined) on 7.8.0+ servers and clobbers the event-based badge. - Use the authoritative aggregate count carried by the 'unread-changed' event instead of the incremental per-subscription map, which could undercount rooms unread before the listeners attached. * style: destructure detail from unread-changed event Satisfy prefer-destructuring lint rule.

ARCH-1606
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Open 2 sessions and test notifications:
The unread count should be reflected on favicon
Further comments
This pull request refactors the Rocket.Chat codebase by removing the
unreadfunctionality from Meteor and introducing a new custom React hook nameduseUnread. TheuseUnreadhook is responsible for calculating the total unread count from user subscriptions, updating a session variable, and managing the browser's favicon based on user preferences for unread alerts. It also triggers global events when there are changes to the unread status. Additionally, theuseUnreadhook has been integrated into theLoggedInAreacomponent within theMainLayout.