mirror of https://github.com/vector-im/riot-web
Merge pull request #3786 from matrix-org/t3chguy/serialize_file_uploads
Serialize file uploads into room to match confirmation dialog orderpull/21833/head
commit
c79bd791d6
|
@ -422,6 +422,9 @@ export default class ContentMessages {
|
||||||
|
|
||||||
const UploadConfirmDialog = sdk.getComponent("dialogs.UploadConfirmDialog");
|
const UploadConfirmDialog = sdk.getComponent("dialogs.UploadConfirmDialog");
|
||||||
let uploadAll = false;
|
let uploadAll = false;
|
||||||
|
// Promise to complete before sending next file into room, used for synchronisation of file-sending
|
||||||
|
// to match the order the files were specified in
|
||||||
|
let promBefore = Promise.resolve();
|
||||||
for (let i = 0; i < okFiles.length; ++i) {
|
for (let i = 0; i < okFiles.length; ++i) {
|
||||||
const file = okFiles[i];
|
const file = okFiles[i];
|
||||||
if (!uploadAll) {
|
if (!uploadAll) {
|
||||||
|
@ -440,11 +443,11 @@ export default class ContentMessages {
|
||||||
});
|
});
|
||||||
if (!shouldContinue) break;
|
if (!shouldContinue) break;
|
||||||
}
|
}
|
||||||
this._sendContentToRoom(file, roomId, matrixClient);
|
promBefore = this._sendContentToRoom(file, roomId, matrixClient, promBefore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendContentToRoom(file, roomId, matrixClient) {
|
_sendContentToRoom(file, roomId, matrixClient, promBefore) {
|
||||||
const content = {
|
const content = {
|
||||||
body: file.name || 'Attachment',
|
body: file.name || 'Attachment',
|
||||||
info: {
|
info: {
|
||||||
|
@ -517,7 +520,10 @@ export default class ContentMessages {
|
||||||
content.file = result.file;
|
content.file = result.file;
|
||||||
content.url = result.url;
|
content.url = result.url;
|
||||||
});
|
});
|
||||||
}).then(function(url) {
|
}).then((url) => {
|
||||||
|
// Await previous message being sent into the room
|
||||||
|
return promBefore;
|
||||||
|
}).then(function() {
|
||||||
return matrixClient.sendMessage(roomId, content);
|
return matrixClient.sendMessage(roomId, content);
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
error = err;
|
error = err;
|
||||||
|
|
Loading…
Reference in New Issue