Apply new ESLint rules to legacy code

This commit is contained in:
Chris Svenningsen 2020-09-08 17:46:29 -07:00 committed by Scott Nonnenberg
parent 91cf075697
commit 8a2c17f65f
70 changed files with 376 additions and 516 deletions

View file

@ -17,8 +17,6 @@ $('.environment').text(states.join(' - '));
// Install the 'dismiss with escape key' handler
$(document).on('keydown', e => {
'use strict';
if (e.keyCode === 27) {
window.closeAbout();
}

View file

@ -14,8 +14,6 @@
// eslint-disable-next-line func-names
(async function() {
'use strict';
const eventHandlerQueue = new window.PQueue({ concurrency: 1 });
Whisper.deliveryReceiptQueue = new window.PQueue({
concurrency: 1,
@ -817,7 +815,8 @@
const target = toSearch[i];
if (!unreadOnly) {
return target.id;
} else if (target.unreadCount > 0) {
}
if (target.unreadCount > 0) {
return target.id;
}
}

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
// Browser specific functions for Chrom*
window.extension = window.extension || {};

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
window.Whisper.Database.id = window.Whisper.Database.id || 'signal';

View file

@ -2,8 +2,6 @@
/* global Whisper: false */
$(document).on('keydown', e => {
'use strict';
if (e.keyCode === 27) {
window.closeDebugLog();
}

View file

@ -9,8 +9,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.Deletes = new (Backbone.Collection.extend({
forMessage(message) {

View file

@ -10,8 +10,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.DeliveryReceipts = new (Backbone.Collection.extend({

View file

@ -9,8 +9,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
async function destroyExpiredMessages() {

View file

@ -6,8 +6,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
async function eraseTapToViewMessages() {

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.KeyChangeListener = {

View file

@ -1,7 +1,5 @@
/* global $ */
$(() => {
'use strict';
$('.message').text(window.i18n('optimizingApplication'));
});

View file

@ -1,6 +1,5 @@
/* eslint-env node */
/* eslint strict: ['error', 'never'] */
/* eslint-disable no-console */
const electron = require('electron');

View file

@ -1,7 +1,5 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const messageLookup = Object.create(null);

View file

@ -8,8 +8,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.MessageRequests = new (Backbone.Collection.extend({
forConversation(conversation) {

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
const BLOCKED_NUMBERS_ID = 'blocked';
const BLOCKED_UUIDS_ID = 'blocked-uuids';
const BLOCKED_GROUPS_ID = 'blocked-groups';

View file

@ -16,8 +16,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const SEALED_SENDER = {
@ -852,7 +850,7 @@
{ syncMessage: true }
);
const contactSendOptions = this.getSendOptions();
const options = Object.assign({}, sendOptions, contactSendOptions);
const options = { ...sendOptions, ...contactSendOptions };
const promise = textsecure.storage.protocol.loadIdentityKey(e164);
return promise.then(key =>

View file

@ -16,8 +16,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const {
@ -157,42 +155,50 @@
type: 'unsupportedMessage',
data: this.getPropsForUnsupportedMessage(),
};
} else if (this.isMessageHistoryUnsynced()) {
}
if (this.isMessageHistoryUnsynced()) {
return {
type: 'linkNotification',
data: null,
};
} else if (this.isExpirationTimerUpdate()) {
}
if (this.isExpirationTimerUpdate()) {
return {
type: 'timerNotification',
data: this.getPropsForTimerNotification(),
};
} else if (this.isKeyChange()) {
}
if (this.isKeyChange()) {
return {
type: 'safetyNumberNotification',
data: this.getPropsForSafetyNumberNotification(),
};
} else if (this.isVerifiedChange()) {
}
if (this.isVerifiedChange()) {
return {
type: 'verificationNotification',
data: this.getPropsForVerificationNotification(),
};
} else if (this.isGroupUpdate()) {
}
if (this.isGroupUpdate()) {
return {
type: 'groupNotification',
data: this.getPropsForGroupNotification(),
};
} else if (this.isEndSession()) {
}
if (this.isEndSession()) {
return {
type: 'resetSessionNotification',
data: this.getPropsForResetSessionNotification(),
};
} else if (this.isCallHistory()) {
}
if (this.isCallHistory()) {
return {
type: 'callHistory',
data: this.getPropsForCallHistory(),
};
} else if (this.isProfileChange()) {
}
if (this.isProfileChange()) {
return {
type: 'profileChange',
data: this.getPropsForProfileChange(),
@ -421,7 +427,8 @@
...basicProps,
type: 'fromSync',
};
} else if (sourceId && sourceId === ourId) {
}
if (sourceId && sourceId === ourId) {
return {
...basicProps,
type: 'fromMe',
@ -875,14 +882,13 @@
const thumbnailWithObjectUrl =
!path && !objectUrl
? null
: Object.assign({}, attachment.thumbnail || {}, {
objectUrl: path || objectUrl,
});
: { ...(attachment.thumbnail || {}), objectUrl: path || objectUrl };
return Object.assign({}, attachment, {
return {
...attachment,
isVoiceMessage: Signal.Types.Attachment.isVoiceMessage(attachment),
thumbnail: thumbnailWithObjectUrl,
});
};
},
getNotificationData() /* : { text: string, emoji?: string } */ {
@ -916,7 +922,8 @@
text: i18n('message--getDescription--disappearing-photo'),
emoji: '📷',
};
} else if (Attachment.isVideo(attachments)) {
}
if (Attachment.isVideo(attachments)) {
return {
text: i18n('message--getDescription--disappearing-video'),
emoji: '🎥',
@ -934,7 +941,8 @@
if (groupUpdate.left === 'You') {
return { text: i18n('youLeftTheGroup') };
} else if (groupUpdate.left) {
}
if (groupUpdate.left) {
return {
text: i18n('leftTheGroup', [
this.getNameForNumber(groupUpdate.left),
@ -1015,22 +1023,26 @@
text: body || i18n('message--getNotificationText--gif'),
emoji: '🎡',
};
} else if (Attachment.isImage(attachments)) {
}
if (Attachment.isImage(attachments)) {
return {
text: body || i18n('message--getNotificationText--photo'),
emoji: '📷',
};
} else if (Attachment.isVideo(attachments)) {
}
if (Attachment.isVideo(attachments)) {
return {
text: body || i18n('message--getNotificationText--video'),
emoji: '🎥',
};
} else if (Attachment.isVoiceMessage(attachment)) {
}
if (Attachment.isVoiceMessage(attachment)) {
return {
text: body || i18n('message--getNotificationText--voice-message'),
emoji: '🎤',
};
} else if (Attachment.isAudio(attachments)) {
}
if (Attachment.isAudio(attachments)) {
return {
text: body || i18n('message--getNotificationText--audio-message'),
emoji: '🔈',
@ -2361,14 +2373,16 @@
confirm();
return;
} else if (isUpdate) {
}
if (isUpdate) {
window.log.warn(
`handleDataMessage: Received update transcript, but no existing entry for message ${message.idForLogging()}. Dropping.`
);
confirm();
return;
} else if (existingMessage) {
}
if (existingMessage) {
window.log.warn(
`handleDataMessage: Received duplicate transcript for message ${message.idForLogging()}, but it was not an update transcript. Dropping.`
);

View file

@ -7,17 +7,13 @@ const DEFAULT_JPEG_QUALITY = 0.85;
// Documentation for `options` (`LoadImageOptions`):
// https://github.com/blueimp/JavaScript-Load-Image/tree/v2.18.0#options
exports.autoOrientImage = (fileOrBlobOrURL, options = {}) => {
const optionsWithDefaults = Object.assign(
{
type: 'image/jpeg',
quality: DEFAULT_JPEG_QUALITY,
},
options,
{
canvas: true,
orientation: true,
}
);
const optionsWithDefaults = {
type: 'image/jpeg',
quality: DEFAULT_JPEG_QUALITY,
...options,
canvas: true,
orientation: true,
};
return new Promise((resolve, reject) => {
loadImage(

View file

@ -459,12 +459,7 @@ async function writeQuoteThumbnails(quotedAttachments, options) {
try {
await Promise.all(
_.map(quotedAttachments, (attachment, index) =>
writeQuoteThumbnail(
attachment,
Object.assign({}, options, {
index,
})
)
writeQuoteThumbnail(attachment, { ...options, index })
)
);
} catch (error) {
@ -531,12 +526,7 @@ async function writeAttachments(attachments, options) {
const { name } = options;
const promises = _.map(attachments, (attachment, index) =>
writeAttachment(
attachment,
Object.assign({}, options, {
index,
})
)
writeAttachment(attachment, { ...options, index })
);
try {
await Promise.all(promises);
@ -575,14 +565,7 @@ async function writeContactAvatars(contact, options) {
try {
await Promise.all(
_.map(contact, (item, index) =>
writeAvatar(
item,
Object.assign({}, options, {
index,
})
)
)
_.map(contact, (item, index) => writeAvatar(item, { ...options, index }))
);
} catch (error) {
window.log.error(
@ -620,12 +603,7 @@ async function writePreviews(preview, options) {
try {
await Promise.all(
_.map(preview, (item, index) =>
writePreviewImage(
item,
Object.assign({}, options, {
index,
})
)
writePreviewImage(item, { ...options, index })
)
);
} catch (error) {
@ -1236,12 +1214,11 @@ async function exportToDirectory(directory, options) {
const attachmentsDir = await createDirectory(directory, 'attachments');
await exportConversationListToFile(stagingDir);
await exportConversations(
Object.assign({}, options, {
messagesDir: stagingDir,
attachmentsDir,
})
);
await exportConversations({
...options,
messagesDir: stagingDir,
attachmentsDir,
});
const archivePath = path.join(directory, ARCHIVE_NAME);
await compressArchive(archivePath, stagingDir);
@ -1281,10 +1258,7 @@ async function importFromDirectory(directory, options) {
loadConversationLookup(),
]);
const [messageLookup, conversationLookup] = lookups;
options = Object.assign({}, options, {
messageLookup,
conversationLookup,
});
options = { ...options, messageLookup, conversationLookup };
const archivePath = path.join(directory, ARCHIVE_NAME);
if (fs.existsSync(archivePath)) {
@ -1312,11 +1286,9 @@ async function importFromDirectory(directory, options) {
await decryptFile(archivePath, decryptedArchivePath, options);
await decompressArchive(decryptedArchivePath, stagingDir);
options = Object.assign({}, options, {
attachmentsDir,
});
options = { ...options, attachmentsDir };
const result = await importNonMessages(stagingDir, options);
await importConversations(stagingDir, Object.assign({}, options));
await importConversations(stagingDir, { ...options });
window.log.info('Done importing from backup!');
return result;

View file

@ -111,20 +111,22 @@ const createRandomMessage = async ({ conversationId } = {}) => {
const _createMessage = ({ commonProperties, conversationId, type } = {}) => {
switch (type) {
case 'incoming':
return Object.assign({}, commonProperties, {
return {
...commonProperties,
flags: 0,
source: conversationId,
sourceDevice: 1,
});
};
case 'outgoing':
return Object.assign({}, commonProperties, {
return {
...commonProperties,
delivered: 1,
delivered_to: [conversationId],
expireTimer: 0,
recipients: [conversationId],
sent_to: [conversationId],
synced: true,
});
};
default:
throw new TypeError(`Unknown message type: '${type}'`);
}

View file

@ -34,7 +34,8 @@ exports.setup = (locale, messages) => {
const { message } = entry;
if (!substitutions) {
return message;
} else if (Array.isArray(substitutions)) {
}
if (Array.isArray(substitutions)) {
return substitutions.reduce(
(result, substitution) => result.replace(/\$.+?\$/, substitution),
message

View file

@ -175,15 +175,20 @@ const KB = 1024;
function getChunkPattern(size, initialOffset) {
if (size > MB) {
return _getRequestPattern(size, MB, initialOffset);
} else if (size > 500 * KB) {
}
if (size > 500 * KB) {
return _getRequestPattern(size, 500 * KB, initialOffset);
} else if (size > 100 * KB) {
}
if (size > 100 * KB) {
return _getRequestPattern(size, 100 * KB, initialOffset);
} else if (size > 50 * KB) {
}
if (size > 50 * KB) {
return _getRequestPattern(size, 50 * KB, initialOffset);
} else if (size > 10 * KB) {
}
if (size > 10 * KB) {
return _getRequestPattern(size, 10 * KB, initialOffset);
} else if (size > KB) {
}
if (size > KB) {
return _getRequestPattern(size, KB, initialOffset);
}

View file

@ -1,14 +1,14 @@
const is = require('@sindresorhus/is');
const AttachmentTS = require('../../../ts/types/Attachment');
const GoogleChrome = require('../../../ts/util/GoogleChrome');
const MIME = require('../../../ts/types/MIME');
const { toLogFormat } = require('./errors');
const {
arrayBufferToBlob,
blobToArrayBuffer,
dataURLToBlob,
} = require('blob-util');
const AttachmentTS = require('../../../ts/types/Attachment');
const GoogleChrome = require('../../../ts/util/GoogleChrome');
const MIME = require('../../../ts/types/MIME');
const { toLogFormat } = require('./errors');
const { autoOrientImage } = require('../auto_orient_image');
const {
migrateDataToFileSystem,
@ -73,10 +73,11 @@ exports.autoOrientJPEG = async attachment => {
// retain it but due to reports of data loss, we dont want to overburden IndexedDB
// by potentially doubling stored image data.
// See: https://github.com/signalapp/Signal-Desktop/issues/1589
const newAttachment = Object.assign({}, attachment, {
const newAttachment = {
...attachment,
data: newDataArrayBuffer,
size: newDataArrayBuffer.byteLength,
});
};
// `digest` is no longer valid for auto-oriented image data, so we discard it:
delete newAttachment.digest;
@ -103,9 +104,7 @@ exports._replaceUnicodeOrderOverridesSync = attachment => {
INVALID_CHARACTERS_PATTERN,
UNICODE_REPLACEMENT_CHARACTER
);
const newAttachment = Object.assign({}, attachment, {
fileName: normalizedFilename,
});
const newAttachment = { ...attachment, fileName: normalizedFilename };
return newAttachment;
};
@ -145,7 +144,7 @@ exports.removeSchemaVersion = ({ attachment, logger }) => {
return attachment;
}
const attachmentWithoutSchemaVersion = Object.assign({}, attachment);
const attachmentWithoutSchemaVersion = { ...attachment };
delete attachmentWithoutSchemaVersion.schemaVersion;
return attachmentWithoutSchemaVersion;
};
@ -179,7 +178,7 @@ exports.loadData = readAttachmentData => {
}
const data = await readAttachmentData(attachment.path);
return Object.assign({}, attachment, { data, size: data.byteLength });
return { ...attachment, data, size: data.byteLength };
};
};

View file

@ -32,8 +32,6 @@ exports.migrateDataToFileSystem = async (
const path = await writeNewAttachmentData(data);
const attachmentWithoutData = omit(Object.assign({}, attachment, { path }), [
'data',
]);
const attachmentWithoutData = omit({ ...attachment, path }, ['data']);
return attachmentWithoutData;
};

View file

@ -17,15 +17,17 @@ exports.parseAndWriteAvatar = upgradeAttachment => async (
const { avatar } = contact;
// This is to ensure that an omit() call doesn't pull in prototype props/methods
const contactShallowCopy = Object.assign({}, contact);
const contactShallowCopy = { ...contact };
const contactWithUpdatedAvatar =
avatar && avatar.avatar
? Object.assign({}, contactShallowCopy, {
avatar: Object.assign({}, avatar, {
? {
...contactShallowCopy,
avatar: {
...avatar,
avatar: await upgradeAttachment(avatar.avatar, context),
}),
})
},
}
: omit(contactShallowCopy, ['avatar']);
// eliminates empty numbers, emails, and addresses; adds type if not provided
@ -50,14 +52,13 @@ function parseContact(contact, options = {}) {
const boundParsePhone = phoneNumber =>
parsePhoneItem(phoneNumber, { regionCode });
return Object.assign(
{},
omit(contact, ['avatar', 'number', 'email', 'address']),
parseAvatar(contact.avatar),
createArrayKey('number', compact(map(contact.number, boundParsePhone))),
createArrayKey('email', compact(map(contact.email, parseEmailItem))),
createArrayKey('address', compact(map(contact.address, parseAddress)))
);
return {
...omit(contact, ['avatar', 'number', 'email', 'address']),
...parseAvatar(contact.avatar),
...createArrayKey('number', compact(map(contact.number, boundParsePhone))),
...createArrayKey('email', compact(map(contact.email, parseEmailItem))),
...createArrayKey('address', compact(map(contact.address, parseAddress))),
};
}
function idForLogging(message) {
@ -94,10 +95,11 @@ function parsePhoneItem(item, options = {}) {
return null;
}
return Object.assign({}, item, {
return {
...item,
type: item.type || DEFAULT_PHONE_TYPE,
value: parsePhoneNumber(item.value, { regionCode }),
});
};
}
function parseEmailItem(item) {
@ -105,9 +107,7 @@ function parseEmailItem(item) {
return null;
}
return Object.assign({}, item, {
type: item.type || DEFAULT_EMAIL_TYPE,
});
return { ...item, type: item.type || DEFAULT_EMAIL_TYPE };
}
function parseAddress(address) {
@ -127,9 +127,7 @@ function parseAddress(address) {
return null;
}
return Object.assign({}, address, {
type: address.type || DEFAULT_ADDRESS_TYPE,
});
return { ...address, type: address.type || DEFAULT_ADDRESS_TYPE };
}
function parseAvatar(avatar) {
@ -138,9 +136,7 @@ function parseAvatar(avatar) {
}
return {
avatar: Object.assign({}, avatar, {
isProfile: avatar.isProfile || false,
}),
avatar: { ...avatar, isProfile: avatar.isProfile || false },
};
}

View file

@ -72,9 +72,7 @@ exports.initializeSchemaVersion = ({ message, logger }) => {
: 0;
const hasAttachments = numAttachments > 0;
if (!hasAttachments) {
return Object.assign({}, message, {
schemaVersion: INITIAL_SCHEMA_VERSION,
});
return { ...message, schemaVersion: INITIAL_SCHEMA_VERSION };
}
// All attachments should have the same schema version, so we just pick
@ -85,12 +83,13 @@ exports.initializeSchemaVersion = ({ message, logger }) => {
)
? firstAttachment.schemaVersion
: INITIAL_SCHEMA_VERSION;
const messageWithInitialSchema = Object.assign({}, message, {
const messageWithInitialSchema = {
...message,
schemaVersion: inheritedSchemaVersion,
attachments: message.attachments.map(attachment =>
Attachment.removeSchemaVersion({ attachment, logger })
),
});
};
return messageWithInitialSchema;
};
@ -158,7 +157,7 @@ exports._withSchemaVersion = ({ schemaVersion, upgrade }) => {
return message;
}
return Object.assign({}, upgradedMessage, { schemaVersion });
return { ...upgradedMessage, schemaVersion };
};
};
@ -172,7 +171,7 @@ exports._mapAttachments = upgradeAttachment => async (message, context) => {
const attachments = await Promise.all(
(message.attachments || []).map(upgradeWithContext)
);
return Object.assign({}, message, { attachments });
return { ...message, attachments };
};
// Public API
@ -180,13 +179,13 @@ exports._mapAttachments = upgradeAttachment => async (message, context) => {
// (Message, Context) ->
// Promise Message
exports._mapContact = upgradeContact => async (message, context) => {
const contextWithMessage = Object.assign({}, context, { message });
const contextWithMessage = { ...context, message };
const upgradeWithContext = contact =>
upgradeContact(contact, contextWithMessage);
const contact = await Promise.all(
(message.contact || []).map(upgradeWithContext)
);
return Object.assign({}, message, { contact });
return { ...message, contact };
};
// _mapQuotedAttachments :: (QuotedAttachment -> Promise QuotedAttachment) ->
@ -210,9 +209,7 @@ exports._mapQuotedAttachments = upgradeAttachment => async (
}
const upgradedThumbnail = await upgradeAttachment(thumbnail, context);
return Object.assign({}, attachment, {
thumbnail: upgradedThumbnail,
});
return { ...attachment, thumbnail: upgradedThumbnail };
};
const quotedAttachments = (message.quote && message.quote.attachments) || [];
@ -220,11 +217,7 @@ exports._mapQuotedAttachments = upgradeAttachment => async (
const attachments = await Promise.all(
quotedAttachments.map(upgradeWithContext)
);
return Object.assign({}, message, {
quote: Object.assign({}, message.quote, {
attachments,
}),
});
return { ...message, quote: { ...message.quote, attachments } };
};
// _mapPreviewAttachments :: (PreviewAttachment -> Promise PreviewAttachment) ->
@ -248,17 +241,13 @@ exports._mapPreviewAttachments = upgradeAttachment => async (
}
const upgradedImage = await upgradeAttachment(image, context);
return Object.assign({}, preview, {
image: upgradedImage,
});
return { ...preview, image: upgradedImage };
};
const preview = await Promise.all(
(message.preview || []).map(upgradeWithContext)
);
return Object.assign({}, message, {
preview,
});
return { ...message, preview };
};
const toVersion0 = async (message, context) =>
@ -533,12 +522,10 @@ exports.createAttachmentLoader = loadAttachmentData => {
);
}
return async message =>
Object.assign({}, message, {
attachments: await Promise.all(
message.attachments.map(loadAttachmentData)
),
});
return async message => ({
...message,
attachments: await Promise.all(message.attachments.map(loadAttachmentData)),
});
};
exports.loadQuoteData = loadAttachmentData => {
@ -767,11 +754,10 @@ exports.createAttachmentDataWriter = ({
await writeExistingAttachmentData(avatar.avatar);
return Object.assign({}, messageContact, {
avatar: Object.assign({}, avatar, {
avatar: omit(avatar.avatar, ['data']),
}),
});
return {
...messageContact,
avatar: { ...avatar, avatar: omit(avatar.avatar, ['data']) },
};
};
const writePreviewImage = async item => {
@ -782,41 +768,36 @@ exports.createAttachmentDataWriter = ({
await writeExistingAttachmentData(image);
return Object.assign({}, item, {
image: omit(image, ['data']),
});
return { ...item, image: omit(image, ['data']) };
};
const messageWithoutAttachmentData = Object.assign(
{},
await writeThumbnails(message, { logger }),
{
contact: await Promise.all((contact || []).map(writeContactAvatar)),
preview: await Promise.all((preview || []).map(writePreviewImage)),
attachments: await Promise.all(
(attachments || []).map(async attachment => {
await writeExistingAttachmentData(attachment);
const messageWithoutAttachmentData = {
...(await writeThumbnails(message, { logger })),
contact: await Promise.all((contact || []).map(writeContactAvatar)),
preview: await Promise.all((preview || []).map(writePreviewImage)),
attachments: await Promise.all(
(attachments || []).map(async attachment => {
await writeExistingAttachmentData(attachment);
if (attachment.screenshot && attachment.screenshot.data) {
await writeExistingAttachmentData(attachment.screenshot);
}
if (attachment.thumbnail && attachment.thumbnail.data) {
await writeExistingAttachmentData(attachment.thumbnail);
}
if (attachment.screenshot && attachment.screenshot.data) {
await writeExistingAttachmentData(attachment.screenshot);
}
if (attachment.thumbnail && attachment.thumbnail.data) {
await writeExistingAttachmentData(attachment.thumbnail);
}
return {
...omit(attachment, ['data']),
...(attachment.thumbnail
? { thumbnail: omit(attachment.thumbnail, ['data']) }
: null),
...(attachment.screenshot
? { screenshot: omit(attachment.screenshot, ['data']) }
: null),
};
})
),
}
);
return {
...omit(attachment, ['data']),
...(attachment.thumbnail
? { thumbnail: omit(attachment.thumbnail, ['data']) }
: null),
...(attachment.screenshot
? { screenshot: omit(attachment.screenshot, ['data']) }
: null),
};
})
),
};
return messageWithoutAttachmentData;
};

View file

@ -1,9 +1,9 @@
/* global document, URL, Blob */
const loadImage = require('blueimp-load-image');
const { toLogFormat } = require('./errors');
const dataURLToBlobSync = require('blueimp-canvas-to-blob');
const { blobToArrayBuffer } = require('blob-util');
const { toLogFormat } = require('./errors');
const {
arrayBufferToObjectURL,
} = require('../../../ts/util/arrayBufferToObjectURL');

View file

@ -9,8 +9,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const { Settings } = Signal.Types;

View file

@ -1,8 +1,6 @@
/* global $, Whisper, i18n */
$(document).on('keydown', e => {
'use strict';
if (e.keyCode === 27) {
window.closePermissionsPopup();
}
@ -11,8 +9,6 @@ $(document).on('keydown', e => {
const $body = $(document.body);
async function applyTheme() {
'use strict';
const theme = await window.getThemeSetting();
$body.removeClass('light-theme');
$body.removeClass('dark-theme');
@ -22,8 +18,6 @@ async function applyTheme() {
applyTheme();
window.subscribeToSystemThemeChange(() => {
'use strict';
applyTheme();
});
@ -42,8 +36,6 @@ window.view = new Whisper.ConfirmationDialogView({
message,
okText: i18n('allowAccess'),
resolve: () => {
'use strict';
if (!window.forCamera) {
window.setMediaPermissions(true);
} else {

View file

@ -9,8 +9,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.Reactions = new (Backbone.Collection.extend({
forMessage(message) {

View file

@ -10,8 +10,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ReadReceipts = new (Backbone.Collection.extend({
forMessage(conversation, message) {

View file

@ -8,8 +8,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ReadSyncs = new (Backbone.Collection.extend({
forMessage(message) {

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const ROTATION_INTERVAL = 48 * 60 * 60 * 1000;
let timeout;

View file

@ -1,8 +1,6 @@
/* global $, Whisper */
$(document).on('keydown', e => {
'use strict';
if (e.keyCode === 27) {
window.closeSettings();
}
@ -11,8 +9,6 @@ $(document).on('keydown', e => {
const $body = $(document.body);
async function applyTheme() {
'use strict';
const theme = await window.getThemeSetting();
$body.removeClass('light-theme');
$body.removeClass('dark-theme');
@ -22,12 +18,9 @@ async function applyTheme() {
applyTheme();
window.subscribeToSystemThemeChange(() => {
'use strict';
applyTheme();
});
// eslint-disable-next-line strict
const getInitialData = async () => ({
deviceName: await window.getDeviceName(),
@ -57,15 +50,11 @@ window.initialRequest = getInitialData();
// eslint-disable-next-line more/no-then
window.initialRequest.then(
data => {
'use strict';
window.initialData = data;
window.view = new Whisper.SettingsView();
window.view.$el.appendTo($body);
},
error => {
'use strict';
window.log.error(
'settings.initialRequest error:',
error && error.stack ? error.stack : error

View file

@ -5,8 +5,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
const TIMESTAMP_THRESHOLD = 5 * 1000; // 5 seconds
const Direction = {
SENDING: 1,
@ -635,7 +633,8 @@
await this.archiveSiblingSessions(encodedAddress);
return true;
} else if (this.isNonBlockingApprovalRequired(identityRecord)) {
}
if (this.isNonBlockingApprovalRequired(identityRecord)) {
window.log.info('Setting approval status...');
identityRecord.nonblockingApproval = nonblockingApproval;

View file

@ -3,8 +3,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
let ready = false;

View file

@ -8,8 +8,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ViewSyncs = new (Backbone.Collection.extend({
forMessage(message) {

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
function resolveTheme() {

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.BannerView = Whisper.View.extend({

View file

@ -5,8 +5,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const { Logs } = window.Signal;

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ConfirmationDialogView = Whisper.View.extend({

View file

@ -3,8 +3,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ContactListView = Whisper.ListView.extend({

View file

@ -14,8 +14,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
const FIVE_MINUTES = 1000 * 60 * 5;
window.Whisper = window.Whisper || {};
@ -2717,14 +2715,15 @@
Component: window.Signal.Components.Quote,
elCallback: el =>
this.$(this.compositionApi.current.attSlotRef.current).prepend(el),
props: Object.assign({}, props, {
props: {
...props,
withContentAbove: true,
onClose: () => {
// This can't be the normal 'onClose' because that is always run when this
// view is removed from the DOM, and would clear the draft quote.
this.setQuoteMessage(null);
},
}),
},
});
},

View file

@ -3,8 +3,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.LinkedCopiedToast = Whisper.ToastView.extend({

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
// TODO: take a title string which could replace the 'members' header

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
/*

View file

@ -7,8 +7,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.StickerPackInstallFailedToast = Whisper.ToastView.extend({

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const Steps = {

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.KeyVerificationPanelView = Whisper.View.extend({

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
/*

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.PhoneInputView = Whisper.View.extend({

View file

@ -5,8 +5,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
window.Whisper.ReactWrapperView = Backbone.View.extend({
@ -66,12 +64,13 @@
});
},
augmentProps(props) {
return Object.assign({}, props, {
return {
...props,
close: () => {
this.remove();
},
i18n,
});
};
},
remove() {
if (this.onClose) {

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.RecorderView = Whisper.View.extend({

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.SafetyNumberChangeDialogView = Whisper.View.extend({

View file

@ -6,8 +6,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const { Settings } = window.Signal.Types;

View file

@ -4,8 +4,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.StandaloneRegistrationView = Whisper.View.extend({

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.ToastView = Whisper.View.extend({

View file

@ -22,8 +22,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.View = Backbone.View.extend(

View file

@ -2,8 +2,6 @@
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
let lastTime;