@@ -422,6 +422,9 @@ export default class ContentMessages {
422422
423423 const UploadConfirmDialog = sdk . getComponent ( "dialogs.UploadConfirmDialog" ) ;
424424 let uploadAll = false ;
425+ // Promise to complete before sending next file into room, used for synchronisation of file-sending
426+ // to match the order the files were specified in
427+ let promBefore = Promise . resolve ( ) ;
425428 for ( let i = 0 ; i < okFiles . length ; ++ i ) {
426429 const file = okFiles [ i ] ;
427430 if ( ! uploadAll ) {
@@ -440,11 +443,11 @@ export default class ContentMessages {
440443 } ) ;
441444 if ( ! shouldContinue ) break ;
442445 }
443- this . _sendContentToRoom ( file , roomId , matrixClient ) ;
446+ promBefore = this . _sendContentToRoom ( file , roomId , matrixClient , promBefore ) ;
444447 }
445448 }
446449
447- _sendContentToRoom ( file , roomId , matrixClient ) {
450+ _sendContentToRoom ( file , roomId , matrixClient , promBefore ) {
448451 const content = {
449452 body : file . name || 'Attachment' ,
450453 info : {
@@ -517,7 +520,10 @@ export default class ContentMessages {
517520 content . file = result . file ;
518521 content . url = result . url ;
519522 } ) ;
520- } ) . then ( function ( url ) {
523+ } ) . then ( ( url ) => {
524+ // Await previous message being sent into the room
525+ return promBefore ;
526+ } ) . then ( function ( ) {
521527 return matrixClient . sendMessage ( roomId , content ) ;
522528 } , function ( err ) {
523529 error = err ;
0 commit comments