Eliminate eslint-generated triple-parents

pull/1/head
Scott Nonnenberg 7 years ago
parent 5c2936bdd6
commit 5602241a0c
No known key found for this signature in database
GPG Key ID: 5F82280C35134661

@ -867,9 +867,9 @@
unreadMessages = unreadMessages.filter(m => Boolean(m.isIncoming())); unreadMessages = unreadMessages.filter(m => Boolean(m.isIncoming()));
const unreadCount = unreadMessages.length - read.length; const unreadCount = unreadMessages.length - read.length;
const promise = new Promise(((resolve, reject) => { const promise = new Promise((resolve, reject) => {
this.save({ unreadCount }).then(resolve, reject); this.save({ unreadCount }).then(resolve, reject);
})); });
promises.push(promise); promises.push(promise);
// If a message has errors, we don't want to send anything out about it. // If a message has errors, we don't want to send anything out about it.
@ -1018,13 +1018,13 @@
}); });
}, },
setProfileKey(key) { setProfileKey(key) {
return new Promise(((resolve, reject) => { return new Promise((resolve, reject) => {
if (!constantTimeEqualArrayBuffers(this.get('profileKey'), key)) { if (!constantTimeEqualArrayBuffers(this.get('profileKey'), key)) {
this.save({ profileKey: key }).then(resolve, reject); this.save({ profileKey: key }).then(resolve, reject);
} else { } else {
resolve(); resolve();
} }
})); });
}, },
fetchMessages() { fetchMessages() {
@ -1205,14 +1205,14 @@
}, },
getNotificationIcon() { getNotificationIcon() {
return new Promise(((resolve) => { return new Promise((resolve) => {
const avatar = this.getAvatar(); const avatar = this.getAvatar();
if (avatar.url) { if (avatar.url) {
resolve(avatar.url); resolve(avatar.url);
} else { } else {
resolve(new Whisper.IdenticonSVGView(avatar).getDataUrl()); resolve(new Whisper.IdenticonSVGView(avatar).getDataUrl());
} }
})); });
}, },
notify(message) { notify(message) {
@ -1264,9 +1264,9 @@
}, },
destroyAll() { destroyAll() {
return Promise.all(this.models.map(m => new Promise(((resolve, reject) => { return Promise.all(this.models.map(m => new Promise((resolve, reject) => {
m.destroy().then(resolve).fail(reject); m.destroy().then(resolve).fail(reject);
})))); })));
}, },
search(providedQuery) { search(providedQuery) {
@ -1276,7 +1276,7 @@
const lastCharCode = query.charCodeAt(query.length - 1); const lastCharCode = query.charCodeAt(query.length - 1);
const nextChar = String.fromCharCode(lastCharCode + 1); const nextChar = String.fromCharCode(lastCharCode + 1);
const upper = query.slice(0, -1) + nextChar; const upper = query.slice(0, -1) + nextChar;
return new Promise(((resolve) => { return new Promise((resolve) => {
this.fetch({ this.fetch({
index: { index: {
name: 'search', // 'search' index on tokens array name: 'search', // 'search' index on tokens array
@ -1285,31 +1285,31 @@
excludeUpper: true, excludeUpper: true,
}, },
}).always(resolve); }).always(resolve);
})); });
} }
return Promise.resolve(); return Promise.resolve();
}, },
fetchAlphabetical() { fetchAlphabetical() {
return new Promise(((resolve) => { return new Promise((resolve) => {
this.fetch({ this.fetch({
index: { index: {
name: 'search', // 'search' index on tokens array name: 'search', // 'search' index on tokens array
}, },
limit: 100, limit: 100,
}).always(resolve); }).always(resolve);
})); });
}, },
fetchGroups(number) { fetchGroups(number) {
return new Promise(((resolve) => { return new Promise((resolve) => {
this.fetch({ this.fetch({
index: { index: {
name: 'group', name: 'group',
only: number, only: number,
}, },
}).always(resolve); }).always(resolve);
})); });
}, },
}); });
@ -1321,14 +1321,14 @@
storeName: 'conversations', storeName: 'conversations',
model: Whisper.Conversation, model: Whisper.Conversation,
fetchGroups(number) { fetchGroups(number) {
return new Promise(((resolve) => { return new Promise((resolve) => {
this.fetch({ this.fetch({
index: { index: {
name: 'group', name: 'group',
only: number, only: number,
}, },
}).always(resolve); }).always(resolve);
})); });
}, },
}); });
}()); }());

@ -420,7 +420,7 @@
const GROUP_TYPES = textsecure.protobuf.GroupContext.Type; const GROUP_TYPES = textsecure.protobuf.GroupContext.Type;
const conversation = ConversationController.get(conversationId); const conversation = ConversationController.get(conversationId);
return conversation.queueJob(() => new Promise(((resolve) => { return conversation.queueJob(() => new Promise((resolve) => {
const now = new Date().getTime(); const now = new Date().getTime();
let attributes = { type: 'private' }; let attributes = { type: 'private' };
if (dataMessage.group) { if (dataMessage.group) {
@ -637,7 +637,7 @@
}); });
}, handleError); }, handleError);
}, handleError); }, handleError);
}))); }));
}, },
markRead(readAt) { markRead(readAt) {
this.unset('unread'); this.unset('unread');
@ -647,9 +647,9 @@
Whisper.Notifications.remove(Whisper.Notifications.where({ Whisper.Notifications.remove(Whisper.Notifications.where({
messageId: this.id, messageId: this.id,
})); }));
return new Promise(((resolve, reject) => { return new Promise((resolve, reject) => {
this.save().then(resolve, reject); this.save().then(resolve, reject);
})); });
}, },
isExpiring() { isExpiring() {
return this.get('expireTimer') && this.get('expirationStartTimestamp'); return this.get('expireTimer') && this.get('expirationStartTimestamp');
@ -708,9 +708,9 @@
} }
}, },
destroyAll() { destroyAll() {
return Promise.all(this.models.map(m => new Promise(((resolve, reject) => { return Promise.all(this.models.map(m => new Promise((resolve, reject) => {
m.destroy().then(resolve).fail(reject); m.destroy().then(resolve).fail(reject);
})))); })));
}, },
fetchSentAt(timestamp) { fetchSentAt(timestamp) {
@ -745,7 +745,7 @@
if (unreadCount > 0) { if (unreadCount > 0) {
startingLoadedUnread = this.getLoadedUnreadCount(); startingLoadedUnread = this.getLoadedUnreadCount();
} }
return new Promise(((resolve) => { return new Promise((resolve) => {
let upper; let upper;
if (this.length === 0) { if (this.length === 0) {
// fetch the most recent messages first // fetch the most recent messages first
@ -765,7 +765,7 @@
// received_at DESC // received_at DESC
}; };
this.fetch(options).always(resolve); this.fetch(options).always(resolve);
})).then(() => { }).then(() => {
if (unreadCount <= 0) { if (unreadCount <= 0) {
return Promise.resolve(); return Promise.resolve();
} }

@ -395,7 +395,7 @@ MessageReceiver.prototype.extend({
return -1; return -1;
}, },
onDeliveryReceipt(envelope) { onDeliveryReceipt(envelope) {
return new Promise(((resolve, reject) => { return new Promise((resolve, reject) => {
const ev = new Event('delivery'); const ev = new Event('delivery');
ev.confirm = this.removeFromCache.bind(this, envelope); ev.confirm = this.removeFromCache.bind(this, envelope);
ev.deliveryReceipt = { ev.deliveryReceipt = {
@ -404,7 +404,7 @@ MessageReceiver.prototype.extend({
sourceDevice: envelope.sourceDevice, sourceDevice: envelope.sourceDevice,
}; };
this.dispatchAndWait(ev).then(resolve, reject); this.dispatchAndWait(ev).then(resolve, reject);
})); });
}, },
unpad(paddedData) { unpad(paddedData) {
const paddedPlaintext = new Uint8Array(paddedData); const paddedPlaintext = new Uint8Array(paddedData);

Loading…
Cancel
Save