diff --git a/components/dashboard/src/teams/JoinTeam.tsx b/components/dashboard/src/teams/JoinTeam.tsx index 4eda2f85e5bcca..715202d2ccec62 100644 --- a/components/dashboard/src/teams/JoinTeam.tsx +++ b/components/dashboard/src/teams/JoinTeam.tsx @@ -24,7 +24,21 @@ export default function() { if (!inviteId) { throw new Error('This invite URL is incorrect.'); } - const team = await getGitpodService().server.joinTeam(inviteId); + + let team; + try { + team = await getGitpodService().server.joinTeam(inviteId); + } catch (error) { + const message: string | undefined = error && typeof error.message === "string" && error.message; + const regExp = /You are already a member of this team. \((.*)\)/; + const match = message && regExp.exec(message); + if (match && match[1]) { + const slug = match[1]; + history.push(`/t/${slug}/members`); + return; + } + throw error; + } const teams = await getGitpodService().server.getTeams(); setTeams(teams); @@ -44,5 +58,5 @@ export default function() { useEffect(() => { document.title = 'Joining Team — Gitpod' }, []); - return