chore: migrate DirectoryView to Hooks#7359
Conversation
|
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)
🚧 Files skipped from review as they are similar to previous changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
WalkthroughDirectoryView is refactored from a Redux-connected class component to a hook-based functional component. A new ChangesDirectoryView functional refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/views/DirectoryView/hooks/useDirectorySearch.ts`:
- Line 44: The code calls
announceSearchResultsForAccessibility(directories.count) which reports the
current page size and fires on load-more; change it to announce the total result
count only for fresh searches by invoking announceSearchResultsForAccessibility
with the total count (e.g., directories.total or directories.totalCount) and
only when a new search is started — detect a fresh search by comparing the
current query/filters or page/offset reset (e.g., page === 1 or queryRef change)
inside useDirectorySearch, and skip the announcement when handling loadMore.
- Around line 20-43: The debounced load function can apply out-of-order
responses, so add a sequencing guard: create a mutable requestId ref (e.g.,
currentRequestId via useRef) and increment it each time load starts (especially
when newSearch) and capture the id in the async call; after awaiting
getDirectory, only call setData, setTotal, and setLoading if the captured id
matches currentRequestId.current. Use the existing load, getDirectory, setData,
setTotal, and setLoading symbols to locate where to increment/capture/check the
request id and drop results from stale requests.
In `@app/views/DirectoryView/index.tsx`:
- Around line 96-98: The local wrapper goRoom currently calls goRoomMethod({
item, isMasterDetail }) without returning or awaiting its promise, so rejections
are swallowed; change goRoom (in DirectoryView/index.tsx) to return the promise
(e.g., return goRoomMethod(...)) or mark it async and await/return the result,
and update the call sites that invoke goRoom (for example the calls passing {
rid: result.room._id, ... } and goRoom(subscription)) to await the call or
handle the returned promise so errors can be caught (e.g., use await goRoom(...)
inside async handlers or attach .catch where appropriate). Ensure all references
to goRoom and goRoomMethod are updated consistently so rejections propagate to
callers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b9807ad-9800-4c67-adaf-a1106a2de71a
📒 Files selected for processing (5)
app/lib/methods/helpers/announceSearchResultsForAccessibility.tsapp/lib/methods/helpers/index.tsapp/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/DirectoryView/index.tsxapp/views/RoomsListView/hooks/useSearch.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: E2E Build Android / android-build
- GitHub Check: ESLint and Test / run-eslint-and-test
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions
Files:
app/lib/methods/helpers/index.tsapp/lib/methods/helpers/announceSearchResultsForAccessibility.tsapp/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/RoomsListView/hooks/useSearch.tsapp/views/DirectoryView/index.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbersUse TypeScript with strict mode and baseUrl set to app/ for import resolution
Files:
app/lib/methods/helpers/index.tsapp/lib/methods/helpers/announceSearchResultsForAccessibility.tsapp/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/RoomsListView/hooks/useSearch.tsapp/views/DirectoryView/index.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use Prettier with tabs, single quotes, 130 char width, no trailing commas, arrow parens avoid, bracket same line
Use@rocket.chat/eslint-configbase with React, React Native, TypeScript, Jest plugins
Files:
app/lib/methods/helpers/index.tsapp/lib/methods/helpers/announceSearchResultsForAccessibility.tsapp/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/RoomsListView/hooks/useSearch.tsapp/views/DirectoryView/index.tsx
app/views/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
View components (70+ screen components) should be placed in app/views/ directory
Files:
app/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/RoomsListView/hooks/useSearch.tsapp/views/DirectoryView/index.tsx
🧠 Learnings (1)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.
Applied to files:
app/lib/methods/helpers/index.tsapp/lib/methods/helpers/announceSearchResultsForAccessibility.tsapp/views/DirectoryView/hooks/useDirectorySearch.tsapp/views/RoomsListView/hooks/useSearch.tsapp/views/DirectoryView/index.tsx
🔇 Additional comments (5)
app/lib/methods/helpers/announceSearchResultsForAccessibility.ts (1)
1-13: LGTM!app/lib/methods/helpers/index.ts (1)
21-21: LGTM!app/views/DirectoryView/hooks/useDirectorySearch.ts (1)
1-19: LGTM!Also applies to: 54-103
app/views/DirectoryView/index.tsx (1)
1-95: LGTM!Also applies to: 140-219
app/views/RoomsListView/hooks/useSearch.ts (1)
6-6: LGTM!
Proposed changes
Migrate DirectoryView to Hooks.
Issue(s)
https://rocketchat.atlassian.net/browse/NATIVE-16
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Summary by CodeRabbit
New Features
Refactor