@@ -471,11 +471,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
471
471
) ;
472
472
} , 1000 ) ;
473
473
474
- private getFallbackHsUrl ( ) : string | null {
474
+ private getFallbackHsUrl ( ) : string | undefined {
475
475
if ( this . props . serverConfig ?. isDefault ) {
476
- return this . props . config . fallback_hs_url ?? null ;
477
- } else {
478
- return null ;
476
+ return this . props . config . fallback_hs_url ;
479
477
}
480
478
}
481
479
@@ -577,7 +575,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
577
575
if ( payload . event_type === "m.identity_server" ) {
578
576
const fullUrl = payload . event_content ? payload . event_content [ "base_url" ] : null ;
579
577
if ( ! fullUrl ) {
580
- MatrixClientPeg . get ( ) . setIdentityServerUrl ( null ) ;
578
+ MatrixClientPeg . get ( ) . setIdentityServerUrl ( undefined ) ;
581
579
localStorage . removeItem ( "mx_is_access_token" ) ;
582
580
localStorage . removeItem ( "mx_is_url" ) ;
583
581
} else {
@@ -1229,6 +1227,10 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1229
1227
* @returns {string } The room ID of the new room, or null if no room was created
1230
1228
*/
1231
1229
private async startWelcomeUserChat ( ) : Promise < string | null > {
1230
+ const snakedConfig = new SnakedObject < IConfigOptions > ( this . props . config ) ;
1231
+ const welcomeUserId = snakedConfig . get ( "welcome_user_id" ) ;
1232
+ if ( ! welcomeUserId ) return null ;
1233
+
1232
1234
// We can end up with multiple tabs post-registration where the user
1233
1235
// might then end up with a session and we don't want them all making
1234
1236
// a chat with the welcome user: try to de-dupe.
@@ -1242,8 +1244,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1242
1244
}
1243
1245
await waitFor ;
1244
1246
1245
- const snakedConfig = new SnakedObject < IConfigOptions > ( this . props . config ) ;
1246
- const welcomeUserRooms = DMRoomMap . shared ( ) . getDMRoomsForUserId ( snakedConfig . get ( "welcome_user_id" ) ) ;
1247
+ const welcomeUserRooms = DMRoomMap . shared ( ) . getDMRoomsForUserId ( welcomeUserId ) ;
1247
1248
if ( welcomeUserRooms . length === 0 ) {
1248
1249
const roomId = await createRoom ( {
1249
1250
dmUserId : snakedConfig . get ( "welcome_user_id" ) ,
@@ -1260,7 +1261,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1260
1261
// user room (it doesn't wait for new data from the server, just
1261
1262
// the saved sync to be loaded).
1262
1263
const saveWelcomeUser = ( ev : MatrixEvent ) : void => {
1263
- if ( ev . getType ( ) === EventType . Direct && ev . getContent ( ) [ snakedConfig . get ( "welcome_user_id" ) ] ) {
1264
+ if ( ev . getType ( ) === EventType . Direct && ev . getContent ( ) [ welcomeUserId ] ) {
1264
1265
MatrixClientPeg . get ( ) . store . save ( true ) ;
1265
1266
MatrixClientPeg . get ( ) . removeListener ( ClientEvent . AccountData , saveWelcomeUser ) ;
1266
1267
}
0 commit comments