Skip to content

refactor: migrate RoomView to a function component - #7482

Merged
diegolmello merged 356 commits into
developfrom
native-34-roomview-hooks
Sep 14, 2026
Merged

diegolmello merged 356 commits into
developfrom
native-34-roomview-hooks

Conversation

@diegolmello

@diegolmello diegolmello commented Jul 9, 2026

Copy link
Copy Markdown
Member

Proposed changes

Converted RoomView from a large class component to a function component, splitting its logic into smaller hooks, stores, and components. Added tests around room state, navigation, and message actions to help preserve existing behavior.

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-34

How to test or reproduce

Use a room end to end (send/edit/quote/react, drafts, autocomplete, threads, jump-to-message, join a not-subscribed room, header actions) on phone and tablet, plus an omnichannel/livechat room. Behavior should match the base branch.

Screenshots

No visual changes intended.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

None.

diegolmello and others added 30 commits July 7, 2026 16:43
Resolve conflicts in MessagesView/SearchMessagesView: keep MessageRoomProvider
wrapping while adopting develop's insets/paddingBottom on the FlatList.
The Timestamp story renders a fixed unix time with the relative (`R`)
format, so its snapshot drifts with wall-clock time (`2 years ago` -> `a year ago`).
…e (NATIVE-22)

Replace the writable module-level fallbackStore with a frozen inertStore whose
actions throw on call, closing the latent cross-room write vector for
no-provider consumers (search/pinned rows). Document useIsBeingEdited's
graceful-degradation contract via JSDoc, and expand the test suite: no-provider
isolation, useIsBeingEdited across all kinds, addQuote dedup guard, clear() from
each kind.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lands the message-action-store map into native-22-message-hooks. Pure
refactor of the interaction store — no intended behavior change.

- Rename InteractionStore -> MessageActionStore, normalize action verbs
- Collapse useMessageAction + useSelectedMessages into one useMessageAction()
- Harden the no-provider fallback with an inert MessageActionStore

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…IVE-22)

Relocates MessageActionStore from views/RoomView into containers/message/stores
so reusable layers no longer import upward from a view, and moves the
TMessageActionState discriminated union into app/definitions (where the
derived TMessageAction already lives), inverting the definitions -> views
arrow. RoomView/ShareView keep creating and providing the store.
…s (NATIVE-22)

JitsiBranch rendered a bare <Content /> after the refactor, and
useIsInfoMessage() explicitly excludes jitsi_call_started (it isn't a
compact/non-touchable info row), so InfoContent never rendered the
localized "started a call" line — only the join button remained.

Give Content a local isInfo override so JitsiBranch alone can force
InfoContent, matching the pre-refactor output (User + Started_call text
+ join button) without touching useIsInfoMessage or any other branch.

Add a jitsi_call_started story to cover it going forward.
Ticket 004: confirmed the stuck-false transition bug at the unit level,
but the only caller (useMediaAutoDownload) keys its message list by the
same id, so a real messageId change always remounts the hook with a
fresh seed. Ruled the behavior fix out of scope; kept the test as a
documented contract.
blocks now types to @rocket.chat/ui-kit's LayoutBlock union (the type
already rendered by UiKitMessage), and e2eMentions matches
getE2EEMentions's real return shape. Closes the any hole at the
useBlocks() hook boundary.
Touch.tsx was the only PR-touched message-render-path leaf missing the
directive under compilationMode 'annotation'. No react-hooks lint rule
(use-memo, preserve-manual-memoization) actually detects a missing
directive — they validate useMemo() usage and compiler-preservation of
existing manual memoization, both already enforced via the extended
plugin:react-hooks/recommended config at their default severities
(0 violations). Enabling them explicitly would only duplicate or, if
downgraded to 'warn' per convention, weaken already-clean 'error'
defaults, so .eslintrc.js is left unchanged.
…ntity (#7670)

* refactor: render the empty room background when RoomView mounts without a route identity

* refactor: name the RoomBackground export and type its return

* test(RoomView): drop assertions on a testID the suite can never render

* refactor: keep rid and t required on the room screen props

* refactor: declare tmid on the room screen props
* test: prove RoomMessageActions sheet handle attachment

* refactor: pass RoomMessageActions refs directly

* test: reuse typed store factories in RoomMessageActions test
* test(RoomView): assert an exact-null render in RightButtons routing guards

* test(RoomView): drop composed RightButtons cases duplicated by routing and leaf suites
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.77.0.109609

Comment thread app/containers/message/components/MessageA11yOrder.tsx
Comment thread app/containers/message/stores/MessageRoomStore.tsx Outdated
Comment thread app/views/RoomView/components/MessageRow.tsx Outdated
Comment thread app/views/RoomView/components/RoomMessageActions.tsx Outdated
Comment thread app/views/RoomView/hooks/useGoRoomActionsView.ts Outdated
Comment thread app/views/RoomView/List/hooks/useScroll.ts
Comment thread app/views/RoomView/services/getLocalAnchor.ts
Comment thread app/views/RoomView/reactCompilerContract.test.ts Outdated
Comment thread jest.config.js Outdated
Comment thread package.json Outdated
#7678)

* chore: drop unused reassure devDependency

* test(MessageComposer): rename media transfer ownership suite after its component

* test(RoomView): move observableDatabase helper out of __tests__
… openThread/openRoom services (#7679)

Rename the hook to useJumpToMessage to match the CONTEXT.md Positional State row.
Move Thread and Room opening into plain async services with explicit deps.
Isolate route-param consumption in a non-exported helper hook so the
generation counter has a single owner. Behavior and public surface unchanged;
the three existing suites pass with only import renames.

NATIVE-1550
… compiler contract test (#7680)

* refactor(MessageActions): read the room at action time instead of during render

* test(RoomView): remove the React Compiler contract test
…itial jump params (#7682)

* refactor(RoomView): split useRoomNavigation into useJumpToMessage and openThread/openRoom services

Rename the hook to useJumpToMessage to match the CONTEXT.md Positional State row.
Move Thread and Room opening into plain async services with explicit deps.
Isolate route-param consumption in a non-exported helper hook so the
generation counter has a single owner. Behavior and public surface unchanged;
the three existing suites pass with only import renames.

NATIVE-1550

* refactor(RoomView): consume initial jump route params in a mount effect instead of InteractionManager
Preserve the RoomView function-component migration while applying develop's application import aliases, including branch-added files and moved components.
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.77.0.109615

@OtavioStasiak OtavioStasiak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just add new i18n label and you can merge!

Comment thread app/i18n/locales/en.json
"room_changed_topic_to": "changed room topic to: {{topic}}",
"room_changed_type": "changed room to {{type}}",
"room_disallowed_reactions": "disallowed reactions",
"Room_failed_to_load": "This room could not be loaded. Check your connection and try again.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing other languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants