Run ESLint on `Conversation::sendMessage`

This commit is contained in:
Daniel Gasienica 2018-02-13 12:35:23 -05:00
parent cd985aa700
commit 674a7357ab
2 changed files with 65 additions and 56 deletions

View File

@ -16,6 +16,7 @@ test/views/*.js
# ES2015+ files # ES2015+ files
!js/background.js !js/background.js
!js/models/conversations.js
!js/views/file_input_view.js !js/views/file_input_view.js
!main.js !main.js
!prepare_build.js !prepare_build.js

View File

@ -1,3 +1,8 @@
/* eslint-disable */
/* global storage: false */
/* global textsecure: false */
/* /*
* vim: ts=4:sw=4:expandtab * vim: ts=4:sw=4:expandtab
*/ */
@ -600,66 +605,69 @@
} }
}, },
sendMessage: function(body, attachments) { /* jshint ignore:start */
this.queueJob(async () => { /* eslint-enable */
var now = Date.now(); sendMessage(body, attachments) {
this.queueJob(async () => {
const now = Date.now();
console.log( console.log(
'Sending message to conversation', 'Sending message to conversation',
this.idForLogging(), this.idForLogging(),
'with timestamp', 'with timestamp',
now now
); );
const processedAttachments = await Promise.all( const processedAttachments = await Promise.all(
attachments.map(Attachment.process) attachments.map(Attachment.process)
); );
var message = this.messageCollection.add({ const message = this.messageCollection.add({
body : body, body,
conversationId : this.id, conversationId: this.id,
type : 'outgoing', type: 'outgoing',
attachments : processedAttachments, attachments: processedAttachments,
sent_at : now, sent_at: now,
received_at : now, received_at: now,
expireTimer : this.get('expireTimer'), expireTimer: this.get('expireTimer'),
recipients : this.getRecipients() recipients: this.getRecipients(),
});
if (this.isPrivate()) {
message.set({destination: this.id});
}
message.save();
this.save({
active_at : now,
timestamp : now,
lastMessage : message.getNotificationText()
});
var sendFunc;
if (this.get('type') == 'private') {
sendFunc = textsecure.messaging.sendMessageToNumber;
}
else {
sendFunc = textsecure.messaging.sendMessageToGroup;
}
var profileKey;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
}
message.send(
sendFunc(
this.get('id'),
body,
processedAttachments,
now,
this.get('expireTimer'),
profileKey
)
);
}); });
if (this.isPrivate()) {
message.set({ destination: this.id });
}
message.save();
this.save({
active_at: now,
timestamp: now,
lastMessage: message.getNotificationText(),
});
let sendFunc;
if (this.get('type') === 'private') {
sendFunc = textsecure.messaging.sendMessageToNumber;
} else {
sendFunc = textsecure.messaging.sendMessageToGroup;
}
let profileKey;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
}
message.send(
sendFunc(
this.get('id'),
body,
processedAttachments,
now,
this.get('expireTimer'),
profileKey
)
);
});
}, },
/* jshint ignore:end */
/* eslint-disable */
updateLastMessage: function() { updateLastMessage: function() {
var collection = new Whisper.MessageCollection(); var collection = new Whisper.MessageCollection();