File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,21 @@ export default function() {
24
24
if ( ! inviteId ) {
25
25
throw new Error ( 'This invite URL is incorrect.' ) ;
26
26
}
27
- const team = await getGitpodService ( ) . server . joinTeam ( inviteId ) ;
27
+
28
+ let team ;
29
+ try {
30
+ team = await getGitpodService ( ) . server . joinTeam ( inviteId ) ;
31
+ } catch ( error ) {
32
+ const message : string | undefined = error && typeof error . message === "string" && error . message ;
33
+ const regExp = / Y o u a r e a l r e a d y a m e m b e r o f t h i s t e a m . \( ( .* ) \) / ;
34
+ const match = message && regExp . exec ( message ) ;
35
+ if ( match && match [ 1 ] ) {
36
+ const slug = match [ 1 ] ;
37
+ history . push ( `/t/${ slug } ` ) ;
38
+ return ;
39
+ }
40
+ throw error ;
41
+ }
28
42
const teams = await getGitpodService ( ) . server . getTeams ( ) ;
29
43
setTeams ( teams ) ;
30
44
@@ -44,5 +58,5 @@ export default function() {
44
58
45
59
useEffect ( ( ) => { document . title = 'Joining Team — Gitpod' } , [ ] ) ;
46
60
47
- return < div className = "mt-16 text-center text-gitpod-red" > { String ( joinError ) } </ div >
61
+ return joinError ? < div className = "mt-16 text-center text-gitpod-red" > { String ( joinError ) } </ div > : < > </ > ;
48
62
}
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ export class TeamDBImpl implements TeamDB {
154
154
const membershipRepo = await this . getMembershipRepo ( ) ;
155
155
const membership = await membershipRepo . findOne ( { teamId, userId, deleted : false } ) ;
156
156
if ( ! ! membership ) {
157
- throw new Error ( ' You are already a member of this team' ) ;
157
+ throw new Error ( ` You are already a member of this team. ( ${ team . slug } )` ) ;
158
158
}
159
159
await membershipRepo . save ( {
160
160
id : uuidv4 ( ) ,
You can’t perform that action at this time.
0 commit comments