RocketChat / RocketChat/Rocket.Chat

refactor(invite): decouple global session state management side-effects from useValidateInviteQuery hook

Open
#39,953 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
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 setLoginDefaultState and Accounts_RegistrationForm checks out of useValidateInviteQuery
  • Migrate the route logic strictly into InvitePage.tsx bound to the query lifecycle
  • Remove // FIXME: decouple this state management from the query

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.