Skip to content

refactor: remove unread from Meteor - #36001

Merged
ggazzo merged 3 commits into
developfrom
refactor/unread
May 26, 2025
Merged

refactor: remove unread from Meteor#36001
ggazzo merged 3 commits into
developfrom
refactor/unread

Conversation

@juliajforesti

@juliajforesti juliajforesti commented May 14, 2025

Copy link
Copy Markdown
Contributor

ARCH-1606

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Open 2 sessions and test notifications:

  • alert
  • mentions
  • user mentions
  • threads

The unread count should be reflected on favicon

Further comments


This pull request refactors the Rocket.Chat codebase by removing the unread functionality from Meteor and introducing a new custom React hook named useUnread. The useUnread hook 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, the useUnread hook has been integrated into the LoggedInArea component within the MainLayout.

@dionisio-bot

dionisio-bot Bot commented May 14, 2025

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.8.0, but it targets 7.7.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented May 14, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0840284

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kody-ai

kody-ai Bot commented May 14, 2025

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-36001/

Built to branch gh-pages at 2025-05-14 22:35 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread apps/meteor/client/hooks/useUnread.ts Outdated
@codecov

codecov Bot commented May 14, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 64.72%. Comparing base (5a74a78) to head (dcb116e).
Report is 49 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 58.44% <93.75%> (+0.03%) ⬆️
unit 71.88% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread apps/meteor/client/hooks/useUnread.ts
@juliajforesti
juliajforesti marked this pull request as ready for review May 15, 2025 13:17
@juliajforesti
juliajforesti requested a review from a team as a code owner May 15, 2025 13:17
@juliajforesti juliajforesti added this to the 7.7.0 milestone May 15, 2025
ggazzo
ggazzo previously requested changes May 15, 2025
Comment thread apps/meteor/client/hooks/useUnread.ts Outdated
Comment thread apps/meteor/client/hooks/useUnread.ts Outdated
@ggazzo
ggazzo dismissed stale reviews from gabriellsh and themself May 15, 2025 18:46

done

@gabriellsh gabriellsh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disaster girl smiling burning house fillette incendie feu maison fille

@ggazzo ggazzo modified the milestones: 7.7.0, 7.8.0 May 20, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label May 26, 2025
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 26, 2025
@ggazzo
ggazzo merged commit 3a1b592 into develop May 26, 2025
@ggazzo
ggazzo deleted the refactor/unread branch May 26, 2025 14:33
jeanfbrito added a commit to RocketChat/Rocket.Chat.Electron that referenced this pull request Jun 25, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants