@@ -24,7 +24,7 @@ import encrypt from "browser-encrypt-attachment";
2424import extractPngChunks from "png-chunks-extract" ;
2525import { IAbortablePromise , IImageInfo } from "matrix-js-sdk/src/@types/partials" ;
2626import { logger } from "matrix-js-sdk/src/logger" ;
27- import { IEventRelation } from "matrix-js-sdk/src" ;
27+ import { IEventRelation , ISendEventResponse } from "matrix-js-sdk/src" ;
2828
2929import { IEncryptedFile , IMediaEventInfo } from "./customisations/models/IMediaEventContent" ;
3030import dis from './dispatcher/dispatcher' ;
@@ -46,6 +46,7 @@ import { IUpload } from "./models/IUpload";
4646import { BlurhashEncoder } from "./BlurhashEncoder" ;
4747import SettingsStore from "./settings/SettingsStore" ;
4848import { decorateStartSendingTime , sendRoundTripMetric } from "./sendTimePerformanceMetrics" ;
49+ import { TimelineRenderingType } from "./contexts/RoomContext" ;
4950
5051const MAX_WIDTH = 800 ;
5152const MAX_HEIGHT = 600 ;
@@ -421,14 +422,14 @@ export default class ContentMessages {
421422 private inprogress : IUpload [ ] = [ ] ;
422423 private mediaConfig : IMediaConfig = null ;
423424
424- sendStickerContentToRoom (
425+ public sendStickerContentToRoom (
425426 url : string ,
426427 roomId : string ,
427428 threadId : string | null ,
428429 info : IImageInfo ,
429430 text : string ,
430431 matrixClient : MatrixClient ,
431- ) {
432+ ) : Promise < ISendEventResponse > {
432433 const startTime = CountlyAnalytics . getTimestamp ( ) ;
433434 const prom = matrixClient . sendStickerMessage ( roomId , threadId , url , info , text ) . catch ( ( e ) => {
434435 logger . warn ( `Failed to send content with URL ${ url } to room ${ roomId } ` , e ) ;
@@ -438,20 +439,21 @@ export default class ContentMessages {
438439 return prom ;
439440 }
440441
441- getUploadLimit ( ) {
442+ public getUploadLimit ( ) : number | null {
442443 if ( this . mediaConfig !== null && this . mediaConfig [ "m.upload.size" ] !== undefined ) {
443444 return this . mediaConfig [ "m.upload.size" ] ;
444445 } else {
445446 return null ;
446447 }
447448 }
448449
449- async sendContentListToRoom (
450+ public async sendContentListToRoom (
450451 files : File [ ] ,
451452 roomId : string ,
452453 relation : IEventRelation | null ,
453454 matrixClient : MatrixClient ,
454- ) {
455+ context = TimelineRenderingType . Room ,
456+ ) : Promise < void > {
455457 if ( matrixClient . isGuest ( ) ) {
456458 dis . dispatch ( { action : 'require_registration' } ) ;
457459 return ;
@@ -530,9 +532,15 @@ export default class ContentMessages {
530532
531533 promBefore = this . sendContentToRoom ( file , roomId , relation , matrixClient , promBefore ) ;
532534 }
535+
536+ // Focus the correct composer
537+ dis . dispatch ( {
538+ action : Action . FocusSendMessageComposer ,
539+ context,
540+ } ) ;
533541 }
534542
535- getCurrentUploads ( relation ?: IEventRelation ) {
543+ public getCurrentUploads ( relation ?: IEventRelation ) : IUpload [ ] {
536544 return this . inprogress . filter ( upload => {
537545 const noRelation = ! relation && ! upload . relation ;
538546 const matchingRelation = relation && upload . relation
@@ -543,7 +551,7 @@ export default class ContentMessages {
543551 } ) ;
544552 }
545553
546- cancelUpload ( promise : Promise < any > , matrixClient : MatrixClient ) {
554+ public cancelUpload ( promise : Promise < any > , matrixClient : MatrixClient ) : void {
547555 let upload : IUpload ;
548556 for ( let i = 0 ; i < this . inprogress . length ; ++ i ) {
549557 if ( this . inprogress [ i ] . promise === promise ) {
@@ -632,9 +640,6 @@ export default class ContentMessages {
632640 this . inprogress . push ( upload ) ;
633641 dis . dispatch < UploadStartedPayload > ( { action : Action . UploadStarted , upload } ) ;
634642
635- // Focus the composer view
636- dis . fire ( Action . FocusSendMessageComposer ) ;
637-
638643 function onProgress ( ev ) {
639644 upload . total = ev . total ;
640645 upload . loaded = ev . loaded ;
0 commit comments