JavaScript inArray()/indexOf() to .includes()

This commit is contained in:
djmaze 2020-07-20 14:33:33 +02:00
parent ec3fd5b7e4
commit db2d95d684
20 changed files with 69 additions and 86 deletions

View file

@ -10,7 +10,7 @@ import {
Notification
} from 'Common/Enums';
import { trim, inArray, convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
import { trim, convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
import { $win } from 'Common/Globals';
import { getNotification, getNotificationFromResponse, reload as translatorReload } from 'Common/Translator';
@ -225,7 +225,7 @@ class LoginUserView extends AbstractViewNext {
}
} else if (oData.ErrorCode) {
this.submitRequest(false);
if (-1 < inArray(oData.ErrorCode, [Notification.InvalidInputArgument])) {
if ([Notification.InvalidInputArgument].includes(oData.ErrorCode)) {
oData.ErrorCode = Notification.AuthError;
}

View file

@ -58,7 +58,7 @@ class FolderListMailBoxUserView extends AbstractViewNext {
() =>
FolderStore.currentFolder() &&
FolderStore.currentFolder().isInbox() &&
-1 < trim(MessageStore.messageListSearch()).indexOf('is:flagged')
trim(MessageStore.messageListSearch()).includes('is:flagged')
);
}

View file

@ -22,7 +22,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { bMobileDevice, popupVisibility, leftPanelDisabled, moveAction } from 'Common/Globals';
import { noop, noopFalse, computedPagenatorHelper, draggablePlace, friendlySize, inArray, isUnd } from 'Common/Utils';
import { noop, noopFalse, computedPagenatorHelper, draggablePlace, friendlySize, isUnd } from 'Common/Utils';
import { mailBox, append } from 'Common/Links';
import { Selector } from 'Common/Selector';
@ -653,7 +653,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
const checked = this.messageListCheckedOrSelected();
if (currentMessage) {
const checkedUids = _.map(checked, (message) => message.uid);
if (0 < checkedUids.length && -1 < inArray(currentMessage.uid, checkedUids)) {
if (0 < checkedUids.length && checkedUids.includes(currentMessage.uid)) {
this.setAction(
currentMessage.folderFullNameRaw,
currentMessage.flagged() ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,

View file

@ -20,7 +20,6 @@ import {
import { $htmlCL, leftPanelDisabled, keyScopeReal, useKeyboardShortcuts, moveAction } from 'Common/Globals';
import {
inArray,
isNonEmptyArray,
trim,
noop,
@ -135,7 +134,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
);
this.downloadAsZipAllowed = ko.computed(
() => -1 < inArray('zip', this.attachmentsActions()) && this.allowAttachmnetControls()
() => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls()
);
this.downloadAsZipLoading = ko.observable(false);
@ -156,7 +155,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
read: this.lastReplyAction_,
write: (value) => {
this.lastReplyAction_(
-1 === inArray(value, [ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward])
[ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value)
? ComposeType.Reply
: value
);