fix: optimistic join data survives subgraph null response#220
Open
fix: optimistic join data survives subgraph null response#220
Conversation
After optimisticJoin, the subgraph hasn't indexed the new member yet, so FETCH_USER_DATA_NEW returns user: null. The query useEffect was clearing all state (userData, hasMemberRole, hasExecRole) which wiped out the optimistic data and showed WelcomeClaimPage instead of profileHub. Added optimisticGuardRef that prevents the null-user branch from clearing state while optimistic data is active. The guard is cleared after 8 seconds when the real subgraph refetch replaces it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
After vouch-first join, the profileHub showed WelcomeClaimPage ("claim your role") instead of the user's profile, even though
optimisticJoincorrectly setuserData.hatIds.Root cause
The
FETCH_USER_DATA_NEWquery fires when profileHub mounts. The subgraph hasn't indexed the new member yet, so it returnsuser: null. The query's useEffect (line 166) then runssetUserData({}), wiping out the optimistichatIds. ProfileHub checksuserData?.hatIds?.length > 0— now it's 0, so WelcomeClaimPage renders.Fix
Added
optimisticGuardRef(a React ref, not state):trueinoptimisticJoin()— blocks the null-user branch from clearing stateTest plan
🤖 Generated with Claude Code