mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Selectively run ESLint on js/background.js
Enabling ESLint on a per function basis allows us to incrementally improve the codebase without requiring large and potentially risky refactorings.
This commit is contained in:
@@ -15,5 +15,6 @@ test/views/*.js
|
||||
/*.js
|
||||
|
||||
# ES2015+ files
|
||||
!js/background.js
|
||||
!main.js
|
||||
!prepare_build.js
|
||||
|
||||
100
js/background.js
100
js/background.js
@@ -1,3 +1,17 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/* eslint-env browser */
|
||||
|
||||
/* global Backbone: false */
|
||||
/* global $: false */
|
||||
|
||||
/* global ConversationController: false */
|
||||
/* global getAccountManager: false */
|
||||
/* global storage: false */
|
||||
/* global textsecure: false */
|
||||
/* global Whisper: false */
|
||||
/* global wrapDeferred: false */
|
||||
|
||||
/*
|
||||
* vim: ts=4:sw=4:expandtab
|
||||
*/
|
||||
@@ -482,49 +496,55 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function onMessageReceived(ev) {
|
||||
const { data } = ev;
|
||||
/* eslint-enable */
|
||||
/* jshint ignore:start */
|
||||
async function onMessageReceived(ev) {
|
||||
const { data } = ev;
|
||||
|
||||
if (data.message.flags & textsecure.protobuf.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
||||
const profileKey = data.message.profileKey.toArrayBuffer();
|
||||
const sender = ConversationController.getOrCreateAndWait(data.source, 'private');
|
||||
await sender.setProfileKey(profileKey);
|
||||
// TODO: Is `ev.confirm` a `Promise`? Original code returned it:
|
||||
return ev.confirm();
|
||||
}
|
||||
|
||||
const message = initIncomingMessage(data);
|
||||
const isDuplicate = await isMessageDuplicate(message);
|
||||
if (isDuplicate) {
|
||||
console.log('Received duplicate message', message.idForLogging());
|
||||
// TODO: Is `ev.confirm` a `Promise`? Original code didn’t return it:
|
||||
return ev.confirm();
|
||||
}
|
||||
|
||||
const { type, id } = data.message.group ?
|
||||
{ type: 'group', id: data.message.group.id } :
|
||||
{ type: 'private', id: data.source };
|
||||
|
||||
const processedData = Object.assign({}, data, {
|
||||
message: Object.assign(
|
||||
{},
|
||||
data.message,
|
||||
{
|
||||
attachments: await Promise.all(
|
||||
data.message.attachments.map(Attachment.process)
|
||||
),
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
await ConversationController.getOrCreateAndWait(id, type);
|
||||
return message.handleDataMessage(
|
||||
processedData.message,
|
||||
ev.confirm,
|
||||
{ initialLoadComplete }
|
||||
);
|
||||
// eslint-disable-next-line no-bitwise
|
||||
if (data.message.flags & textsecure.protobuf.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
||||
const profileKey = data.message.profileKey.toArrayBuffer();
|
||||
const sender = ConversationController.getOrCreateAndWait(data.source, 'private');
|
||||
await sender.setProfileKey(profileKey);
|
||||
// TODO: Is `ev.confirm` a `Promise`? Original code returned it:
|
||||
return ev.confirm();
|
||||
}
|
||||
|
||||
const message = initIncomingMessage(data);
|
||||
const isDuplicate = await isMessageDuplicate(message);
|
||||
|
||||
if (isDuplicate) {
|
||||
console.log('Received duplicate message', message.idForLogging());
|
||||
// TODO: Is `ev.confirm` a `Promise`? Original code didn’t return it:
|
||||
return ev.confirm();
|
||||
}
|
||||
|
||||
const { type, id } = data.message.group ?
|
||||
{ type: 'group', id: data.message.group.id } :
|
||||
{ type: 'private', id: data.source };
|
||||
|
||||
const processedData = Object.assign({}, data, {
|
||||
message: Object.assign(
|
||||
{},
|
||||
data.message,
|
||||
{
|
||||
attachments: await Promise.all(
|
||||
data.message.attachments.map(Attachment.process)
|
||||
),
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
await ConversationController.getOrCreateAndWait(id, type);
|
||||
return message.handleDataMessage(
|
||||
processedData.message,
|
||||
ev.confirm,
|
||||
{ initialLoadComplete }
|
||||
);
|
||||
}
|
||||
/* jshint ignore:end */
|
||||
/* eslint-disable */
|
||||
|
||||
function onSentMessage(ev) {
|
||||
var now = new Date().getTime();
|
||||
var data = ev.data;
|
||||
|
||||
Reference in New Issue
Block a user