@@ -24,7 +24,7 @@ import encrypt from "browser-encrypt-attachment";
24
24
import extractPngChunks from "png-chunks-extract" ;
25
25
import { IAbortablePromise , IImageInfo } from "matrix-js-sdk/src/@types/partials" ;
26
26
import { logger } from "matrix-js-sdk/src/logger" ;
27
- import { IEventRelation } from "matrix-js-sdk/src" ;
27
+ import { IEventRelation , ISendEventResponse } from "matrix-js-sdk/src" ;
28
28
29
29
import { IEncryptedFile , IMediaEventInfo } from "./customisations/models/IMediaEventContent" ;
30
30
import dis from './dispatcher/dispatcher' ;
@@ -46,6 +46,7 @@ import { IUpload } from "./models/IUpload";
46
46
import { BlurhashEncoder } from "./BlurhashEncoder" ;
47
47
import SettingsStore from "./settings/SettingsStore" ;
48
48
import { decorateStartSendingTime , sendRoundTripMetric } from "./sendTimePerformanceMetrics" ;
49
+ import { TimelineRenderingType } from "./contexts/RoomContext" ;
49
50
50
51
const MAX_WIDTH = 800 ;
51
52
const MAX_HEIGHT = 600 ;
@@ -421,14 +422,14 @@ export default class ContentMessages {
421
422
private inprogress : IUpload [ ] = [ ] ;
422
423
private mediaConfig : IMediaConfig = null ;
423
424
424
- sendStickerContentToRoom (
425
+ public sendStickerContentToRoom (
425
426
url : string ,
426
427
roomId : string ,
427
428
threadId : string | null ,
428
429
info : IImageInfo ,
429
430
text : string ,
430
431
matrixClient : MatrixClient ,
431
- ) {
432
+ ) : Promise < ISendEventResponse > {
432
433
const startTime = CountlyAnalytics . getTimestamp ( ) ;
433
434
const prom = matrixClient . sendStickerMessage ( roomId , threadId , url , info , text ) . catch ( ( e ) => {
434
435
logger . warn ( `Failed to send content with URL ${ url } to room ${ roomId } ` , e ) ;
@@ -438,20 +439,21 @@ export default class ContentMessages {
438
439
return prom ;
439
440
}
440
441
441
- getUploadLimit ( ) {
442
+ public getUploadLimit ( ) : number | null {
442
443
if ( this . mediaConfig !== null && this . mediaConfig [ "m.upload.size" ] !== undefined ) {
443
444
return this . mediaConfig [ "m.upload.size" ] ;
444
445
} else {
445
446
return null ;
446
447
}
447
448
}
448
449
449
- async sendContentListToRoom (
450
+ public async sendContentListToRoom (
450
451
files : File [ ] ,
451
452
roomId : string ,
452
453
relation : IEventRelation | null ,
453
454
matrixClient : MatrixClient ,
454
- ) {
455
+ context = TimelineRenderingType . Room ,
456
+ ) : Promise < void > {
455
457
if ( matrixClient . isGuest ( ) ) {
456
458
dis . dispatch ( { action : 'require_registration' } ) ;
457
459
return ;
@@ -530,9 +532,15 @@ export default class ContentMessages {
530
532
531
533
promBefore = this . sendContentToRoom ( file , roomId , relation , matrixClient , promBefore ) ;
532
534
}
535
+
536
+ // Focus the correct composer
537
+ dis . dispatch ( {
538
+ action : Action . FocusSendMessageComposer ,
539
+ context,
540
+ } ) ;
533
541
}
534
542
535
- getCurrentUploads ( relation ?: IEventRelation ) {
543
+ public getCurrentUploads ( relation ?: IEventRelation ) : IUpload [ ] {
536
544
return this . inprogress . filter ( upload => {
537
545
const noRelation = ! relation && ! upload . relation ;
538
546
const matchingRelation = relation && upload . relation
@@ -543,7 +551,7 @@ export default class ContentMessages {
543
551
} ) ;
544
552
}
545
553
546
- cancelUpload ( promise : Promise < any > , matrixClient : MatrixClient ) {
554
+ public cancelUpload ( promise : Promise < any > , matrixClient : MatrixClient ) : void {
547
555
let upload : IUpload ;
548
556
for ( let i = 0 ; i < this . inprogress . length ; ++ i ) {
549
557
if ( this . inprogress [ i ] . promise === promise ) {
@@ -632,9 +640,6 @@ export default class ContentMessages {
632
640
this . inprogress . push ( upload ) ;
633
641
dis . dispatch < UploadStartedPayload > ( { action : Action . UploadStarted , upload } ) ;
634
642
635
- // Focus the composer view
636
- dis . fire ( Action . FocusSendMessageComposer ) ;
637
-
638
643
function onProgress ( ev ) {
639
644
upload . total = ev . total ;
640
645
upload . loaded = ev . loaded ;
0 commit comments