@@ -1832,10 +1832,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1832
1832
* @returns MXID for the logged-in user, or null if not logged in
1833
1833
*/
1834
1834
public getUserId ( ) : string | null {
1835
- if ( this . credentials && this . credentials . userId ) {
1836
- return this . credentials . userId ;
1837
- }
1838
- return null ;
1835
+ return this . credentials ?. userId ?? null ;
1839
1836
}
1840
1837
1841
1838
/**
@@ -1857,7 +1854,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1857
1854
* @returns Domain of this MXID
1858
1855
*/
1859
1856
public getDomain ( ) : string | null {
1860
- if ( this . credentials && this . credentials . userId ) {
1857
+ if ( this . credentials ? .userId ) {
1861
1858
return this . credentials . userId . replace ( / ^ .* ?: / , "" ) ;
1862
1859
}
1863
1860
return null ;
@@ -1868,10 +1865,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1868
1865
* @returns The user ID localpart or null.
1869
1866
*/
1870
1867
public getUserIdLocalpart ( ) : string | null {
1871
- if ( this . credentials && this . credentials . userId ) {
1872
- return this . credentials . userId . split ( ":" ) [ 0 ] . substring ( 1 ) ;
1873
- }
1874
- return null ;
1868
+ return this . credentials ?. userId ?. split ( ":" ) [ 0 ] . substring ( 1 ) ?? null ;
1875
1869
}
1876
1870
1877
1871
/**
@@ -4313,7 +4307,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
4313
4307
*/
4314
4308
public getIgnoredUsers ( ) : string [ ] {
4315
4309
const event = this . getAccountData ( "m.ignored_user_list" ) ;
4316
- if ( ! event || ! event . getContent ( ) || ! event . getContent ( ) [ "ignored_users" ] ) return [ ] ;
4310
+ if ( ! event ? .getContent ( ) [ "ignored_users" ] ) return [ ] ;
4317
4311
return Object . keys ( event . getContent ( ) [ "ignored_users" ] ) ;
4318
4312
}
4319
4313
0 commit comments