RocketChat / RocketChat/Rocket.Chat
refactor(invite): decouple global session state management side-effects from useValidateInviteQuery hook
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Current Behavior
In apps/meteor/client/views/invite/hooks/useValidateInviteQuery.ts, there is an outstanding architectural technical debt marker:
// FIXME: decouple this state management from the query
Currently, useValidateInviteQuery dispatches global session state side-effects (setLoginDefaultState) directly inside its asynchronous queryFn. This violates React Query anti-patterns, blurring the lines between pure data-fetching and UI state mutation, making the hook harder to test and reuse.
Expected Behavior
The setLoginDefaultState side-effects should be extracted completely from the useValidateInviteQuery fetcher logic. Instead, the UI component consuming the data (InvitePage.tsx) should track the query's isSuccess/data state and dispatch the session updates deterministically via a useEffect.
Tasks
- Extract
setLoginDefaultStateandAccounts_RegistrationFormchecks out ofuseValidateInviteQuery - Migrate the route logic strictly into
InvitePage.tsxbound to the query lifecycle - Remove
// FIXME: decouple this state management from the query
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/meteor/client/views/invite/hooks/useValidateInviteQuery.ts and apps/meteor/client/views/invite/InvitePage.tsx. Trace the query lifecycle and the existing setLoginDefaultState and Accounts_RegistrationForm checks, then verify that fetching is separated from session updates and the route handles them on successful query data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- authentication, frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100