@@ -444,6 +444,21 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
444444 }
445445 } ;
446446
447+ /**
448+ * Start the process of actually sending invites or creating a DM.
449+ *
450+ * Called once we have shown the user all the necessary warnings.
451+ */
452+ private async startDmOrSendInvites ( ) : Promise < void > {
453+ if ( this . props . kind === InviteKind . Dm ) {
454+ await this . startDm ( ) ;
455+ } else if ( this . props . kind === InviteKind . Invite ) {
456+ await this . inviteUsers ( ) ;
457+ } else {
458+ throw new Error ( "Unknown InviteKind: " + this . props . kind ) ;
459+ }
460+ }
461+
447462 private transferCall = async ( ) : Promise < void > => {
448463 if ( this . props . kind !== InviteKind . CallTransfer ) return ;
449464 if ( this . state . currentTabId == TabId . UserDirectory ) {
@@ -1129,8 +1144,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
11291144 private renderMainTab ( ) : JSX . Element {
11301145 let helpText ;
11311146 let buttonText ;
1132- let goButtonFn : ( ( ) => Promise < void > ) | null = null ;
1133-
11341147 const identityServersEnabled = SettingsStore . getValue ( UIFeature . IdentityServer ) ;
11351148
11361149 const cli = MatrixClientPeg . safeGet ( ) ;
@@ -1167,7 +1180,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
11671180 }
11681181
11691182 buttonText = _t ( "action|go" ) ;
1170- goButtonFn = this . startDm ;
11711183 } else if ( this . props . kind === InviteKind . Invite ) {
11721184 const roomId = this . props . roomId ;
11731185 const room = MatrixClientPeg . get ( ) ?. getRoom ( roomId ) ;
@@ -1211,19 +1223,22 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
12111223 ) ;
12121224
12131225 buttonText = _t ( "action|invite" ) ;
1214- goButtonFn = this . inviteUsers ;
12151226 } else {
12161227 throw new Error ( "Unknown InviteDialog kind: " + this . props . kind ) ;
12171228 }
12181229
1230+ const onGoButtonPressed = ( ) : void => {
1231+ this . startDmOrSendInvites ( ) . catch ( ( e ) => logErrorAndShowErrorDialog ( "Error processing invites" , e ) ) ;
1232+ } ;
1233+
12191234 return (
12201235 < React . Fragment >
12211236 < p className = "mx_InviteDialog_helpText" > { helpText } </ p >
12221237 < div className = "mx_InviteDialog_addressBar" >
12231238 { this . renderEditor ( ) }
12241239 < AccessibleButton
12251240 kind = "primary"
1226- onClick = { goButtonFn }
1241+ onClick = { onGoButtonPressed }
12271242 className = "mx_InviteDialog_goButton"
12281243 disabled = { this . state . busy || ! this . hasSelection ( ) }
12291244 >
0 commit comments