fix(web): SpaceInviteCard navigates to space on already-member instead of showing error

This commit is contained in:
Jannis Braun
2026-04-29 22:41:49 +02:00
parent bc66ddc633
commit d8b08d8990
2 changed files with 33 additions and 2 deletions
@@ -56,7 +56,15 @@ export function SpaceInviteCard({ payload, senderName }: Props) {
const space = await joinByCode(payload.inviteCode, payload.spaceInstanceOrigin || undefined);
navigate(`/spaces/${space.id}`);
} catch (err) {
setJoinError((err as Error)?.message ?? 'Failed to join');
const msg = (err as Error)?.message ?? '';
if (msg.toLowerCase().includes('already a member')) {
// Already a member is a successful state — just navigate to the space.
// Look up the space in the store by id; if not found (rare race), stay
// silent rather than block the user with a noisy error.
navigate(`/spaces/${payload.spaceId}`);
return;
}
setJoinError(msg || 'Failed to join');
setJoining(false);
}
};