From 674a7357abf0dcc365455695d56c0479998ebf27 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Tue, 13 Feb 2018 12:35:23 -0500 Subject: [PATCH] Run ESLint on `Conversation::sendMessage` --- .eslintignore | 1 + js/models/conversations.js | 120 ++++++++++++++++++++----------------- 2 files changed, 65 insertions(+), 56 deletions(-) diff --git a/.eslintignore b/.eslintignore index c35eb01eb..057712d04 100644 --- a/.eslintignore +++ b/.eslintignore @@ -16,6 +16,7 @@ test/views/*.js # ES2015+ files !js/background.js +!js/models/conversations.js !js/views/file_input_view.js !main.js !prepare_build.js diff --git a/js/models/conversations.js b/js/models/conversations.js index b6d590dee..1f19fae7c 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1,3 +1,8 @@ +/* eslint-disable */ + +/* global storage: false */ +/* global textsecure: false */ + /* * vim: ts=4:sw=4:expandtab */ @@ -600,66 +605,69 @@ } }, - sendMessage: function(body, attachments) { - this.queueJob(async () => { - var now = Date.now(); + /* jshint ignore:start */ + /* eslint-enable */ + sendMessage(body, attachments) { + this.queueJob(async () => { + const now = Date.now(); - console.log( - 'Sending message to conversation', - this.idForLogging(), - 'with timestamp', - now - ); + console.log( + 'Sending message to conversation', + this.idForLogging(), + 'with timestamp', + now + ); - const processedAttachments = await Promise.all( - attachments.map(Attachment.process) - ); - var message = this.messageCollection.add({ - body : body, - conversationId : this.id, - type : 'outgoing', - attachments : processedAttachments, - sent_at : now, - received_at : now, - expireTimer : this.get('expireTimer'), - 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 - ) - ); + const processedAttachments = await Promise.all( + attachments.map(Attachment.process) + ); + const message = this.messageCollection.add({ + body, + conversationId: this.id, + type: 'outgoing', + attachments: processedAttachments, + sent_at: now, + received_at: now, + expireTimer: this.get('expireTimer'), + recipients: this.getRecipients(), }); + 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() { var collection = new Whisper.MessageCollection();