Move attachment processing closer to sending
This helps ensure processing happens uniformly, regardless of which code paths are taken to send an attachment.
This commit is contained in:
parent
532ac3e273
commit
d70d70e52c
|
@ -5,6 +5,8 @@
|
|||
'use strict';
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
const { Attachment } = window.Whisper;
|
||||
|
||||
// TODO: Factor out private and group subclasses of Conversation
|
||||
|
||||
var COLORS = [
|
||||
|
@ -599,7 +601,7 @@
|
|||
},
|
||||
|
||||
sendMessage: function(body, attachments) {
|
||||
this.queueJob(function() {
|
||||
this.queueJob(async () => {
|
||||
var now = Date.now();
|
||||
|
||||
console.log(
|
||||
|
@ -609,11 +611,14 @@
|
|||
now
|
||||
);
|
||||
|
||||
const processedAttachments = await Promise.all(
|
||||
attachments.map(Attachment.process)
|
||||
);
|
||||
var message = this.messageCollection.add({
|
||||
body : body,
|
||||
conversationId : this.id,
|
||||
type : 'outgoing',
|
||||
attachments : attachments,
|
||||
attachments : processedAttachments,
|
||||
sent_at : now,
|
||||
received_at : now,
|
||||
expireTimer : this.get('expireTimer'),
|
||||
|
@ -643,8 +648,17 @@
|
|||
profileKey = storage.get('profileKey');
|
||||
}
|
||||
|
||||
message.send(sendFunc(this.get('id'), body, attachments, now, this.get('expireTimer'), profileKey));
|
||||
}.bind(this));
|
||||
message.send(
|
||||
sendFunc(
|
||||
this.get('id'),
|
||||
body,
|
||||
processedAttachments,
|
||||
now,
|
||||
this.get('expireTimer'),
|
||||
profileKey
|
||||
)
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
updateLastMessage: function() {
|
||||
|
|
|
@ -216,8 +216,7 @@
|
|||
|
||||
return this.autoScale(file)
|
||||
.then(this.readFile)
|
||||
.then(setFlags(attachmentFlags))
|
||||
.then(Attachment.process);
|
||||
.then(setFlags(attachmentFlags));
|
||||
},
|
||||
/* jshint ignore:end */
|
||||
/* eslint-disable */
|
||||
|
|
Loading…
Reference in New Issue