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 @@ -22,7 +22,21 @@ export default function() {
22
22
if ( ! inviteId ) {
23
23
throw new Error ( 'This invite URL is incorrect.' ) ;
24
24
}
25
- const team = await getGitpodService ( ) . server . joinTeam ( inviteId ) ;
25
+
26
+ let team ;
27
+ try {
28
+ team = await getGitpodService ( ) . server . joinTeam ( inviteId ) ;
29
+ } catch ( error ) {
30
+ const message : string | undefined = error && typeof error . message === "string" && error . message ;
31
+ 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 . \( ( .* ) \) / ;
32
+ const match = message && regExp . exec ( message ) ;
33
+ if ( match && match [ 1 ] ) {
34
+ const slug = match [ 1 ] ;
35
+ history . push ( `/t/${ slug } /members` ) ;
36
+ return ;
37
+ }
38
+ throw error ;
39
+ }
26
40
const teams = await getGitpodService ( ) . server . getTeams ( ) ;
27
41
setTeams ( teams ) ;
28
42
@@ -36,5 +50,5 @@ export default function() {
36
50
37
51
useEffect ( ( ) => { document . title = 'Joining Team — Gitpod' } , [ ] ) ;
38
52
39
- return < div className = "mt-16 text-center text-gitpod-red" > { String ( joinError ) } </ div >
53
+ return joinError ? < div className = "mt-16 text-center text-gitpod-red" > { String ( joinError ) } </ div > : < > </ > ;
40
54
}
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