Skip to content

Commit 90a76dd

Browse files
authored
fix(invite): hold the loading state until the stored token resolves (#6488)
Two gaps left by #6486. The query was gated on isTokenResolved but the loading state was not. With enabled: false React Query still reports success when the key already holds data, so a cached null-token entry made isPending false and rendered the accept UI for one frame before the effect applied the stored token. Reachable only on a client-side remount after a tokenless fetch already succeeded. An empty ?token= also stopped falling back to storage: searchParams.get returns '' which is not null, so token became '' where the pre-#6486 truthiness check had read sessionStorage. Normalize to null at the source.
1 parent 5bfcc67 commit 90a76dd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

apps/sim/app/invite/[id]/invite.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ export default function Invite({ registrationDisabled }: InviteProps) {
286286
const isNewUser = searchParams.get('new') === 'true'
287287
const errorReason = searchParams.get('error')
288288
const urlError = errorReason ? getInviteError(errorReason) : null
289-
const tokenFromQuery = searchParams.get('token')
289+
/** `|| null` so an empty `?token=` falls back to storage rather than querying with ''. */
290+
const tokenFromQuery = searchParams.get('token') || null
290291
/**
291292
* Derived during render so the invitation query key is correct on the first
292293
* commit; an effect-set token refetches under a second key whenever the
@@ -308,7 +309,7 @@ export default function Invite({ registrationDisabled }: InviteProps) {
308309
})
309310
const invitation = invitationQuery.data?.invitation ?? null
310311
const joinPreview = invitationQuery.data?.joinPreview ?? null
311-
const isLoading = Boolean(session?.user) && invitationQuery.isPending
312+
const isLoading = Boolean(session?.user) && (!isTokenResolved || invitationQuery.isPending)
312313

313314
const fetchError = invitationQuery.error
314315
? getInviteError(

0 commit comments

Comments
 (0)