refactor: simplify RoomView hooks and List - #7643
Merged
diegolmello merged 1 commit intoSep 3, 2026
Merged
Conversation
…rection Collapse multi-field room store reads into single useShallow selectors, rebuild useUnreadsCount on the shared useObservable helper, remove a duplicate rid subscription and a redundant live-ref layer, give the navigation mirror effect a dependency array, pass RoomHeader props explicitly, and move the two stray List hook tests into __tests__.
diegolmello
requested a deployment
to
approve_e2e_testing
September 3, 2026 19:40 — with
GitHub Actions
Waiting
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (9)
WalkthroughThe changes consolidate Zustand subscriptions, replace manual unread-count subscriptions with ChangesRoom hook maintenance
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: 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 |
diegolmello
requested a deployment
to
ios_build
September 3, 2026 19:43 — with
GitHub Actions
Waiting
diegolmello
requested a deployment
to
android_build
September 3, 2026 19:43 — with
GitHub Actions
Waiting
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.
Proposed changes
Cleanup pass over
RoomView/hooksandRoomView/List, on top of the RoomView hooks migration.useUnreadsCounthand-rolled an rxjssubscribe/setState/unsubscribecycle. It now uses the repo'suseObservablewith the query inuseMemoand the reduce computed during render, matching its siblinguseThreadFollowing. Derived state belongs in render, not in an effect that writes state.useCanPlaceLivechatOnHold(3 subscriptions) anduseGoRoomActionsView(5) each subscribed per field; both are now a singleuseShallowselector, so an unrelated field changing no longer re-renders the consumer.useRoomMessageHandlerssubscribed toridseparately when it already had the room;ridis read off the room now.useJumpToMessagekept anonJumpParamChangedReflive-ref layer thatuseChangedParamalready provides for its ownonChange. Both call sites pass the callback directly.useRoomNavigation's cycle-breaking mirror effect had no dependency array, so it ran on every render. It now depends on[cancelJumpToMessage].useHeaderspread{...headerProps}intoRoomHeader; all 15 props are passed explicitly.__tests__directory. Moved.Issue(s)
https://rocketchat.atlassian.net/browse/NATIVE-34
How to test or reproduce
Open a room and exercise the header, the unread badge, jump-to-message, discussion and thread navigation, and livechat on-hold. Behavior should be unchanged.
Screenshots
Types of changes
Checklist
Further comments
Targets
native-34-roomview-hooks(#7482), not develop.Walkthrough of every change, including the ones rejected: https://claude.ai/code/artifact/8292075a-18cc-48d5-bf3a-b5d0982603b8
One change was attempted and reverted, and is worth recording. Collapsing
useScroll'sonReObserveref and its two layout effects into a singleuseLayoutEffect(onReObserve, [messages])needs anexhaustive-depssuppression, andreactCompilerContract.test.tsthen fails: the suppression makes React Compiler skip optimizing the entire file. That ref and ordering pattern is load-bearing for memoization on the hottest scroll hook, not lint appeasement. Note that the bail set is rule-specific, sinceuseScrollalready carries aset-state-in-effectsuppression that the compiler tolerates, so the contract test is the only reliable check.Left for follow-up:
useHeaderdepends on the wholeroomUpdateobject, sotunreadchurn rebuilds the header on every incoming message. Narrowing it requires the exact field set read bygetRoomTitle/isGroupChat/isInviteSubscription, and getting that wrong silently freezes the header.getRoomInfoplusgoRoomis duplicated betweenuseRoomNavigation.navToRoomanduseRoomMessageHandlers.onDiscussionPress.useDebounce's missing cancel-on-unmount is bolted onto two call sites here; the fix belongs inlib/methods/helpers/debounce.ts, where 21 other call sites have the same leak.useCloseBanneranduseReactionActionsuse no React API, so they are not hooks.Local run: 38 suites, 400 tests pass;
tscclean; no new lint warnings.Summary by CodeRabbit
Bug Fixes
Refactor
Tests