@@ -396,11 +396,7 @@ export default class ContentMessages {
396396 }
397397
398398 public getUploadLimit ( ) : number | null {
399- if ( this . mediaConfig !== null && this . mediaConfig [ "m.upload.size" ] !== undefined ) {
400- return this . mediaConfig [ "m.upload.size" ] ;
401- } else {
402- return null ;
403- }
399+ return this . mediaConfig ?. [ "m.upload.size" ] ?? null ;
404400 }
405401
406402 public async sendContentListToRoom (
@@ -578,7 +574,7 @@ export default class ContentMessages {
578574 logger . error ( e ) ;
579575 content . msgtype = MsgType . File ;
580576 }
581- } else if ( file . type . indexOf ( "audio/" ) === 0 ) {
577+ } else if ( file . type . startsWith ( "audio/" ) ) {
582578 content . msgtype = MsgType . Audio ;
583579 try {
584580 const audioInfo = await infoForAudioFile ( file ) ;
@@ -588,7 +584,7 @@ export default class ContentMessages {
588584 logger . error ( e ) ;
589585 content . msgtype = MsgType . File ;
590586 }
591- } else if ( file . type . indexOf ( "video/" ) === 0 ) {
587+ } else if ( file . type . startsWith ( "video/" ) ) {
592588 content . msgtype = MsgType . Video ;
593589 try {
594590 const videoInfo = await infoForVideoFile ( matrixClient , roomId , file ) ;
@@ -648,11 +644,7 @@ export default class ContentMessages {
648644 }
649645
650646 private isFileSizeAcceptable ( file : File ) : boolean {
651- if (
652- this . mediaConfig !== null &&
653- this . mediaConfig [ "m.upload.size" ] !== undefined &&
654- file . size > this . mediaConfig [ "m.upload.size" ]
655- ) {
647+ if ( this . mediaConfig ?. [ "m.upload.size" ] !== undefined && file . size > this . mediaConfig [ "m.upload.size" ] ) {
656648 return false ;
657649 }
658650 return true ;
0 commit comments