Use Array.includes in place of Array.indexOf

pull/565/head
Maxim Shishmarev 6 years ago
parent a2f836c690
commit 395daf3aba

@ -2728,7 +2728,7 @@
const knownMembers = this.get('members');
if (knownMembers) {
const fromMember = knownMembers.indexOf(sender) !== -1;
const fromMember = knownMembers.includes(sender);
if (!fromMember) {
window.log.warn(

@ -1744,7 +1744,7 @@
const knownMembers = conversation.get('members');
if (!newGroup && knownMembers) {
const fromMember = knownMembers.indexOf(source) !== -1;
const fromMember = knownMembers.includes(source);
if (!fromMember) {
window.log.warn(`Ignoring group message from non-member: ${source}`);
@ -1766,8 +1766,7 @@
);
}
const fromAdmin =
conversation.get('groupAdmins').indexOf(source) !== -1;
const fromAdmin = conversation.get('groupAdmins').includes(source);
if (!fromAdmin) {
// Make sure the message is not removing members / renaming the group
@ -1832,12 +1831,11 @@
if (message.isFriendRequest() && backgroundFrReq) {
// Check if the contact is a member in one of our private groups:
const groupMember =
window
.getConversations()
.models.filter(c => c.get('members'))
.reduce((acc, x) => window.Lodash.concat(acc, x.get('members')), [])
.indexOf(source) !== -1;
const groupMember = window
.getConversations()
.models.filter(c => c.get('members'))
.reduce((acc, x) => window.Lodash.concat(acc, x.get('members')), [])
.includes(source);
if (groupMember) {
window.log.info(
@ -1914,9 +1912,7 @@
if (removedMembers.length > 0) {
if (
removedMembers.indexOf(
textsecure.storage.user.getNumber()
) !== -1
removedMembers.includes(textsecure.storage.user.getNumber())
) {
groupUpdate.kicked = 'You';
attributes.isKickedFromGroup = true;

@ -3,7 +3,7 @@
const electron = require('electron');
// TODO: this results in poor readability, would be
// much better to implicitly call with `_`.
// much better to explicitly call with `_`.
const {
cloneDeep,
forEach,

@ -102,7 +102,7 @@
const ourPK = textsecure.storage.user.getNumber();
this.isAdmin = groupConvo.get('groupAdmins').indexOf(ourPK) !== -1;
this.isAdmin = groupConvo.get('groupAdmins').includes(ourPK);
const convos = window.getConversations().models;

@ -45,7 +45,7 @@ export class UpdateGroupDialog extends React.Component<Props, State> {
const lokiProfile = d.getLokiProfile();
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
const existingMember = this.props.existingMembers.indexOf(d.id) !== -1;
const existingMember = this.props.existingMembers.includes(d.id);
return {
id: d.id,

Loading…
Cancel
Save