mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
JavaScript inArray()/indexOf() to .includes()
This commit is contained in:
parent
ec3fd5b7e4
commit
db2d95d684
20 changed files with 69 additions and 86 deletions
|
|
@ -6,7 +6,7 @@ import progressJs from 'progressJs';
|
||||||
import { root } from 'Common/Links';
|
import { root } from 'Common/Links';
|
||||||
import { getNotification } from 'Common/Translator';
|
import { getNotification } from 'Common/Translator';
|
||||||
import { StorageResultType, Notification } from 'Common/Enums';
|
import { StorageResultType, Notification } from 'Common/Enums';
|
||||||
import { pInt, isNormal, isArray, inArray, isUnd } from 'Common/Utils';
|
import { pInt, isNormal, isArray, isUnd } from 'Common/Utils';
|
||||||
|
|
||||||
import * as Settings from 'Storage/Settings';
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ class AdminApp extends AbstractApp {
|
||||||
if (
|
if (
|
||||||
data &&
|
data &&
|
||||||
data.ErrorCode &&
|
data.ErrorCode &&
|
||||||
-1 < inArray(pInt(data.ErrorCode), [Notification.LicensingServerIsUnavailable, Notification.LicensingExpired])
|
[Notification.LicensingServerIsUnavailable, Notification.LicensingExpired].includes(pInt(data.ErrorCode))
|
||||||
) {
|
) {
|
||||||
LicenseStore.licenseError(getNotification(pInt(data.ErrorCode)));
|
LicenseStore.licenseError(getNotification(pInt(data.ErrorCode)));
|
||||||
LicenseStore.licensing(true);
|
LicenseStore.licensing(true);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import {
|
||||||
log,
|
log,
|
||||||
has,
|
has,
|
||||||
isArray,
|
isArray,
|
||||||
inArray,
|
|
||||||
isUnd,
|
isUnd,
|
||||||
isNormal,
|
isNormal,
|
||||||
isPosNumeric,
|
isPosNumeric,
|
||||||
|
|
@ -342,7 +341,7 @@ class AppUser extends AbstractApp {
|
||||||
} else {
|
} else {
|
||||||
setFolderHash(FolderStore.currentFolderFullNameRaw(), '');
|
setFolderHash(FolderStore.currentFolderFullNameRaw(), '');
|
||||||
|
|
||||||
if (oData && -1 < inArray(oData.ErrorCode, [Notification.CantMoveMessage, Notification.CantCopyMessage])) {
|
if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) {
|
||||||
window.alert(getNotification(oData.ErrorCode));
|
window.alert(getNotification(oData.ErrorCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import _ from '_';
|
||||||
import key from 'key';
|
import key from 'key';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { EventKeyCode } from 'Common/Enums';
|
import { EventKeyCode } from 'Common/Enums';
|
||||||
import { isArray, inArray, noop, noopTrue } from 'Common/Utils';
|
import { isArray, noop, noopTrue } from 'Common/Utils';
|
||||||
|
|
||||||
class Selector {
|
class Selector {
|
||||||
list;
|
list;
|
||||||
|
|
@ -159,7 +159,7 @@ class Selector {
|
||||||
mFocused = null;
|
mFocused = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < len && -1 < inArray(uid, aCheckedCache)) {
|
if (0 < len && aCheckedCache.includes(uid)) {
|
||||||
isChecked = true;
|
isChecked = true;
|
||||||
item.checked(true);
|
item.checked(true);
|
||||||
len -= 1;
|
len -= 1;
|
||||||
|
|
@ -181,7 +181,7 @@ class Selector {
|
||||||
if (null !== isNextFocused) {
|
if (null !== isNextFocused) {
|
||||||
getNext = false;
|
getNext = false;
|
||||||
isNextFocused = _.find(aCache, (sUid) => {
|
isNextFocused = _.find(aCache, (sUid) => {
|
||||||
if (getNext && -1 < inArray(sUid, uids)) {
|
if (getNext && uids.includes(sUid)) {
|
||||||
return sUid;
|
return sUid;
|
||||||
} else if (isNextFocused === sUid) {
|
} else if (isNextFocused === sUid) {
|
||||||
getNext = true;
|
getNext = true;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import _ from '_';
|
||||||
import $ from '$';
|
import $ from '$';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { Notification, UploadErrorCode } from 'Common/Enums';
|
import { Notification, UploadErrorCode } from 'Common/Enums';
|
||||||
import { pInt, isUnd, isNull, has, microtime, inArray } from 'Common/Utils';
|
import { pInt, isUnd, isNull, has, microtime } from 'Common/Utils';
|
||||||
import { $html, $htmlCL } from 'Common/Globals';
|
import { $html, $htmlCL } from 'Common/Globals';
|
||||||
import { reload as momentorReload } from 'Common/Momentor';
|
import { reload as momentorReload } from 'Common/Momentor';
|
||||||
import { langLink } from 'Common/Links';
|
import { langLink } from 'Common/Links';
|
||||||
|
|
@ -274,7 +274,7 @@ export function reload(admin, language) {
|
||||||
() => {
|
() => {
|
||||||
reloadData();
|
reloadData();
|
||||||
|
|
||||||
const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
|
const isRtl = ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir'].includes((language || '').toLowerCase());
|
||||||
|
|
||||||
$htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
|
$htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
|
||||||
// $html.attr('dir', isRtl ? 'rtl' : 'ltr')
|
// $html.attr('dir', isRtl ? 'rtl' : 'ltr')
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ import { Mime } from 'Common/Mime';
|
||||||
import { jassl } from 'Common/Jassl';
|
import { jassl } from 'Common/Jassl';
|
||||||
|
|
||||||
const trim = $.trim;
|
const trim = $.trim;
|
||||||
const inArray = $.inArray;
|
const isArray = Array.isArray;
|
||||||
const isArray = _.isArray;
|
|
||||||
const isObject = _.isObject;
|
const isObject = _.isObject;
|
||||||
const isFunc = _.isFunction;
|
const isFunc = _.isFunction;
|
||||||
const isUnd = _.isUndefined;
|
const isUnd = _.isUndefined;
|
||||||
|
|
@ -22,7 +21,7 @@ const noop = () => {}; // eslint-disable-line no-empty-function
|
||||||
const noopTrue = () => true;
|
const noopTrue = () => true;
|
||||||
const noopFalse = () => false;
|
const noopFalse = () => false;
|
||||||
|
|
||||||
export { trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse, jassl };
|
export { trim, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse, jassl };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} func
|
* @param {Function} func
|
||||||
|
|
@ -935,7 +934,7 @@ export function folderListOptionsBuilder(
|
||||||
seporator: false,
|
seporator: false,
|
||||||
disabled:
|
disabled:
|
||||||
!oItem.selectable ||
|
!oItem.selectable ||
|
||||||
-1 < inArray(oItem.fullNameRaw, aDisabled) ||
|
aDisabled.includes(oItem.fullNameRaw) ||
|
||||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -971,7 +970,7 @@ export function folderListOptionsBuilder(
|
||||||
seporator: false,
|
seporator: false,
|
||||||
disabled:
|
disabled:
|
||||||
!oItem.selectable ||
|
!oItem.selectable ||
|
||||||
-1 < inArray(oItem.fullNameRaw, aDisabled) ||
|
aDisabled.includes(oItem.fullNameRaw) ||
|
||||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
dev/External/ko.js
vendored
9
dev/External/ko.js
vendored
|
|
@ -948,18 +948,17 @@ ko.extenders.posInterer = (target, defaultVal) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
ko.extenders.limitedList = (target, limitedList) => {
|
ko.extenders.limitedList = (target, limitedList) => {
|
||||||
const Utils = require('Common/Utils'),
|
const result = ko
|
||||||
result = ko
|
|
||||||
.computed({
|
.computed({
|
||||||
read: target,
|
read: target,
|
||||||
write: (newValue) => {
|
write: (newValue) => {
|
||||||
const currentValue = ko.unwrap(target),
|
const currentValue = ko.unwrap(target),
|
||||||
list = ko.unwrap(limitedList);
|
list = ko.unwrap(limitedList);
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(list)) {
|
if (Array.isArray(list) && 0 < list.length) {
|
||||||
if (-1 < Utils.inArray(newValue, list)) {
|
if (list.includes(newValue)) {
|
||||||
target(newValue);
|
target(newValue);
|
||||||
} else if (-1 < Utils.inArray(currentValue, list)) {
|
} else if (list.includes(currentValue, list)) {
|
||||||
target(currentValue + ' ');
|
target(currentValue + ' ');
|
||||||
target(currentValue);
|
target(currentValue);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import ko from 'ko';
|
||||||
|
|
||||||
import { FileType } from 'Common/Enums';
|
import { FileType } from 'Common/Enums';
|
||||||
import { bAllowPdfPreview } from 'Common/Globals';
|
import { bAllowPdfPreview } from 'Common/Globals';
|
||||||
import { trim, pInt, inArray, isNonEmptyArray, getFileExtension, friendlySize } from 'Common/Utils';
|
import { trim, pInt, isNonEmptyArray, getFileExtension, friendlySize } from 'Common/Utils';
|
||||||
import {
|
import {
|
||||||
attachmentDownload,
|
attachmentDownload,
|
||||||
attachmentPreview,
|
attachmentPreview,
|
||||||
|
|
@ -30,29 +30,28 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
||||||
const mimeTypeParts = mimeType.split('/');
|
const mimeTypeParts = mimeType.split('/');
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case 'image' === mimeTypeParts[0] || -1 < inArray(ext, ['png', 'jpg', 'jpeg', 'gif', 'bmp']):
|
case 'image' === mimeTypeParts[0] || ['png', 'jpg', 'jpeg', 'gif', 'bmp'].includes(ext):
|
||||||
result = FileType.Image;
|
result = FileType.Image;
|
||||||
break;
|
break;
|
||||||
case 'audio' === mimeTypeParts[0] || -1 < inArray(ext, ['mp3', 'ogg', 'oga', 'wav']):
|
case 'audio' === mimeTypeParts[0] || ['mp3', 'ogg', 'oga', 'wav'].includes(ext):
|
||||||
result = FileType.Audio;
|
result = FileType.Audio;
|
||||||
break;
|
break;
|
||||||
case 'video' === mimeTypeParts[0] || -1 < inArray(ext, ['mkv', 'avi']):
|
case 'video' === mimeTypeParts[0] || ['mkv', 'avi'].includes(ext):
|
||||||
result = FileType.Video;
|
result = FileType.Video;
|
||||||
break;
|
break;
|
||||||
case -1 < inArray(ext, ['php', 'js', 'css']):
|
case ['php', 'js', 'css'].includes(ext):
|
||||||
result = FileType.Code;
|
result = FileType.Code;
|
||||||
break;
|
break;
|
||||||
case 'eml' === ext || -1 < inArray(mimeType, ['message/delivery-status', 'message/rfc822']):
|
case 'eml' === ext || ['message/delivery-status', 'message/rfc822'].includes(mimeType):
|
||||||
result = FileType.Eml;
|
result = FileType.Eml;
|
||||||
break;
|
break;
|
||||||
case ('text' === mimeTypeParts[0] && 'html' !== mimeTypeParts[1]) || -1 < inArray(ext, ['txt', 'log']):
|
case ('text' === mimeTypeParts[0] && 'html' !== mimeTypeParts[1]) || ['txt', 'log'].includes(ext):
|
||||||
result = FileType.Text;
|
result = FileType.Text;
|
||||||
break;
|
break;
|
||||||
case 'text/html' === mimeType || -1 < inArray(ext, ['html']):
|
case 'text/html' === mimeType || ['html'].includes(ext):
|
||||||
result = FileType.Html;
|
result = FileType.Html;
|
||||||
break;
|
break;
|
||||||
case -1 <
|
case [
|
||||||
inArray(mimeTypeParts[1], [
|
|
||||||
'zip',
|
'zip',
|
||||||
'7z',
|
'7z',
|
||||||
'tar',
|
'tar',
|
||||||
|
|
@ -70,21 +69,20 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
||||||
'x-zip-compressed',
|
'x-zip-compressed',
|
||||||
'x-7z-compressed',
|
'x-7z-compressed',
|
||||||
'x-rar-compressed'
|
'x-rar-compressed'
|
||||||
]) || -1 < inArray(ext, ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2']):
|
].includes(mimeTypeParts[1]) || ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2'].includes(ext):
|
||||||
result = FileType.Archive;
|
result = FileType.Archive;
|
||||||
break;
|
break;
|
||||||
case -1 < inArray(mimeTypeParts[1], ['pdf', 'x-pdf']) || -1 < inArray(ext, ['pdf']):
|
case ['pdf', 'x-pdf'].includes(mimeTypeParts[1]) || ['pdf'].includes(ext):
|
||||||
result = FileType.Pdf;
|
result = FileType.Pdf;
|
||||||
break;
|
break;
|
||||||
case -1 < inArray(mimeType, ['application/pgp-signature', 'application/pgp-keys']) ||
|
case ['application/pgp-signature', 'application/pgp-keys'].includes(mimeType) ||
|
||||||
-1 < inArray(ext, ['asc', 'pem', 'ppk']):
|
['asc', 'pem', 'ppk'].includes(ext):
|
||||||
result = FileType.Certificate;
|
result = FileType.Certificate;
|
||||||
break;
|
break;
|
||||||
case -1 < inArray(mimeType, ['application/pkcs7-signature']) || -1 < inArray(ext, ['p7s']):
|
case ['application/pkcs7-signature'].includes(mimeType) || ['p7s'].includes(ext):
|
||||||
result = FileType.CertificateBin;
|
result = FileType.CertificateBin;
|
||||||
break;
|
break;
|
||||||
case -1 <
|
case [
|
||||||
inArray(mimeTypeParts[1], [
|
|
||||||
'rtf',
|
'rtf',
|
||||||
'msword',
|
'msword',
|
||||||
'vnd.msword',
|
'vnd.msword',
|
||||||
|
|
@ -92,11 +90,10 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
||||||
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||||
'vnd.ms-word.document.macroEnabled.12',
|
'vnd.ms-word.document.macroEnabled.12',
|
||||||
'vnd.ms-word.template.macroEnabled.12'
|
'vnd.ms-word.template.macroEnabled.12'
|
||||||
]):
|
].includes(mimeTypeParts[1]):
|
||||||
result = FileType.WordText;
|
result = FileType.WordText;
|
||||||
break;
|
break;
|
||||||
case -1 <
|
case [
|
||||||
inArray(mimeTypeParts[1], [
|
|
||||||
'excel',
|
'excel',
|
||||||
'ms-excel',
|
'ms-excel',
|
||||||
'vnd.ms-excel',
|
'vnd.ms-excel',
|
||||||
|
|
@ -106,11 +103,10 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
||||||
'vnd.ms-excel.template.macroEnabled.12',
|
'vnd.ms-excel.template.macroEnabled.12',
|
||||||
'vnd.ms-excel.addin.macroEnabled.12',
|
'vnd.ms-excel.addin.macroEnabled.12',
|
||||||
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||||
]):
|
].includes(mimeTypeParts[1]):
|
||||||
result = FileType.Sheet;
|
result = FileType.Sheet;
|
||||||
break;
|
break;
|
||||||
case -1 <
|
case [
|
||||||
inArray(mimeTypeParts[1], [
|
|
||||||
'powerpoint',
|
'powerpoint',
|
||||||
'ms-powerpoint',
|
'ms-powerpoint',
|
||||||
'vnd.ms-powerpoint',
|
'vnd.ms-powerpoint',
|
||||||
|
|
@ -121,7 +117,7 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
||||||
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||||
'vnd.ms-powerpoint.template.macroEnabled.12',
|
'vnd.ms-powerpoint.template.macroEnabled.12',
|
||||||
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||||
]):
|
].includes(mimeTypeParts[1]):
|
||||||
result = FileType.Presentation;
|
result = FileType.Presentation;
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import _ from '_';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { FilterRulesType, FiltersAction } from 'Common/Enums';
|
import { FilterRulesType, FiltersAction } from 'Common/Enums';
|
||||||
import { pString, inArray, isNonEmptyArray, fakeMd5, delegateRunOnDestroy, windowResizeCallback } from 'Common/Utils';
|
import { pString, isNonEmptyArray, fakeMd5, delegateRunOnDestroy, windowResizeCallback } from 'Common/Utils';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
import { getFolderFromCacheList } from 'Common/Cache';
|
import { getFolderFromCacheList } from 'Common/Cache';
|
||||||
|
|
||||||
|
|
@ -152,21 +152,19 @@ class FilterModel extends AbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('' === this.actionValue()) {
|
if ('' === this.actionValue()) {
|
||||||
if (
|
if ([
|
||||||
-1 <
|
|
||||||
inArray(this.actionType(), [
|
|
||||||
FiltersAction.MoveTo,
|
FiltersAction.MoveTo,
|
||||||
FiltersAction.Forward,
|
FiltersAction.Forward,
|
||||||
FiltersAction.Reject,
|
FiltersAction.Reject,
|
||||||
FiltersAction.Vacation
|
FiltersAction.Vacation
|
||||||
])
|
].includes(this.actionType())
|
||||||
) {
|
) {
|
||||||
this.actionValue.error(true);
|
this.actionValue.error(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FiltersAction.Forward === this.actionType() && -1 === this.actionValue().indexOf('@')) {
|
if (FiltersAction.Forward === this.actionType() && !this.actionValue().includes('@')) {
|
||||||
this.actionValue.error(true);
|
this.actionValue.error(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +172,7 @@ class FilterModel extends AbstractModel {
|
||||||
if (
|
if (
|
||||||
FiltersAction.Vacation === this.actionType() &&
|
FiltersAction.Vacation === this.actionType() &&
|
||||||
'' !== this.actionValueFourth() &&
|
'' !== this.actionValueFourth() &&
|
||||||
-1 === this.actionValueFourth().indexOf('@')
|
!this.actionValueFourth().includes('@')
|
||||||
) {
|
) {
|
||||||
this.actionValueFourth.error(true);
|
this.actionValueFourth.error(true);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import { DATA_IMAGE_LAZY_PLACEHOLDER_PIC } from 'Common/Consts';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
pInt,
|
pInt,
|
||||||
inArray,
|
|
||||||
isArray,
|
isArray,
|
||||||
isUnd,
|
isUnd,
|
||||||
trim,
|
trim,
|
||||||
|
|
@ -253,7 +252,7 @@ class MessageModel extends AbstractModel {
|
||||||
if (json && 'Object/Message' === json['@Object']) {
|
if (json && 'Object/Message' === json['@Object']) {
|
||||||
priority = pInt(json.Priority);
|
priority = pInt(json.Priority);
|
||||||
this.priority(
|
this.priority(
|
||||||
-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal
|
[MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal
|
||||||
);
|
);
|
||||||
|
|
||||||
this.folderFullNameRaw = json.Folder;
|
this.folderFullNameRaw = json.Folder;
|
||||||
|
|
@ -313,7 +312,7 @@ class MessageModel extends AbstractModel {
|
||||||
if (json && 'Object/Message' === json['@Object']) {
|
if (json && 'Object/Message' === json['@Object']) {
|
||||||
priority = pInt(json.Priority);
|
priority = pInt(json.Priority);
|
||||||
this.priority(
|
this.priority(
|
||||||
-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal
|
[MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal
|
||||||
);
|
);
|
||||||
|
|
||||||
this.aDraftInfo = json.DraftInfo;
|
this.aDraftInfo = json.DraftInfo;
|
||||||
|
|
@ -362,7 +361,7 @@ class MessageModel extends AbstractModel {
|
||||||
if (
|
if (
|
||||||
'' !== attachment.cidWithOutTags &&
|
'' !== attachment.cidWithOutTags &&
|
||||||
0 < this.foundedCIDs.length &&
|
0 < this.foundedCIDs.length &&
|
||||||
0 <= inArray(attachment.cidWithOutTags, this.foundedCIDs)
|
this.foundedCIDs.includes(attachment.cidWithOutTags)
|
||||||
) {
|
) {
|
||||||
attachment.isLinked = true;
|
attachment.isLinked = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import window from 'window';
|
||||||
import $ from '$';
|
import $ from '$';
|
||||||
|
|
||||||
import { ajax } from 'Common/Links';
|
import { ajax } from 'Common/Links';
|
||||||
import { microtime, isUnd, isNormal, pString, pInt, inArray } from 'Common/Utils';
|
import { microtime, isUnd, isNormal, pString, pInt } from 'Common/Utils';
|
||||||
import { DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT } from 'Common/Consts';
|
import { DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT } from 'Common/Consts';
|
||||||
import { StorageResultType, Notification } from 'Common/Enums';
|
import { StorageResultType, Notification } from 'Common/Enums';
|
||||||
import { data as GlobalsData } from 'Common/Globals';
|
import { data as GlobalsData } from 'Common/Globals';
|
||||||
|
|
@ -128,9 +128,7 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
||||||
this.setTrigger(fTrigger, false);
|
this.setTrigger(fTrigger, false);
|
||||||
|
|
||||||
if (errorData) {
|
if (errorData) {
|
||||||
if (
|
if ([
|
||||||
-1 <
|
|
||||||
inArray(errorData.ErrorCode, [
|
|
||||||
Notification.AuthError,
|
Notification.AuthError,
|
||||||
Notification.AccessError,
|
Notification.AccessError,
|
||||||
Notification.ConnectionError,
|
Notification.ConnectionError,
|
||||||
|
|
@ -139,7 +137,7 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
|
||||||
Notification.MailServerError,
|
Notification.MailServerError,
|
||||||
Notification.UnknownNotification,
|
Notification.UnknownNotification,
|
||||||
Notification.UnknownError
|
Notification.UnknownError
|
||||||
])
|
].includes(errorData.ErrorCode)
|
||||||
) {
|
) {
|
||||||
GlobalsData.iAjaxErrorCount += 1;
|
GlobalsData.iAjaxErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import $ from '$';
|
||||||
|
|
||||||
import { TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT, DEFAULT_AJAX_TIMEOUT } from 'Common/Consts';
|
import { TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT, DEFAULT_AJAX_TIMEOUT } from 'Common/Consts';
|
||||||
import { StorageResultType, Notification } from 'Common/Enums';
|
import { StorageResultType, Notification } from 'Common/Enums';
|
||||||
import { inArray, pInt, pString, isUnd } from 'Common/Utils';
|
import { pInt, pString, isUnd } from 'Common/Utils';
|
||||||
import { data as GlobalsData } from 'Common/Globals';
|
import { data as GlobalsData } from 'Common/Globals';
|
||||||
import { ajax } from 'Common/Links';
|
import { ajax } from 'Common/Links';
|
||||||
import { runHook } from 'Common/Plugins';
|
import { runHook } from 'Common/Plugins';
|
||||||
|
|
@ -32,9 +32,7 @@ class AbstractAjaxRemote {
|
||||||
|
|
||||||
if (StorageResultType.Success === sType && oData && !oData.Result) {
|
if (StorageResultType.Success === sType && oData && !oData.Result) {
|
||||||
if (
|
if (
|
||||||
oData &&
|
oData && [
|
||||||
-1 <
|
|
||||||
inArray(oData.ErrorCode, [
|
|
||||||
Notification.AuthError,
|
Notification.AuthError,
|
||||||
Notification.AccessError,
|
Notification.AccessError,
|
||||||
Notification.ConnectionError,
|
Notification.ConnectionError,
|
||||||
|
|
@ -43,7 +41,7 @@ class AbstractAjaxRemote {
|
||||||
Notification.MailServerError,
|
Notification.MailServerError,
|
||||||
Notification.UnknownNotification,
|
Notification.UnknownNotification,
|
||||||
Notification.UnknownError
|
Notification.UnknownError
|
||||||
])
|
].includes(oData.ErrorCode)
|
||||||
) {
|
) {
|
||||||
GlobalsData.iAjaxErrorCount += 1;
|
GlobalsData.iAjaxErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +176,7 @@ class AbstractAjaxRemote {
|
||||||
this.defaultResponse(fResultCallback, action, sType, oData, cached, params);
|
this.defaultResponse(fResultCallback, action, sType, oData, cached, params);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (action && 0 < abortActions.length && -1 < inArray(action, abortActions)) {
|
if (action && 0 < abortActions.length && abortActions.includes(action)) {
|
||||||
if (this.oRequests[action]) {
|
if (this.oRequests[action]) {
|
||||||
this.oRequests[action].__aborted = true;
|
this.oRequests[action].__aborted = true;
|
||||||
if (this.oRequests[action].abort) {
|
if (this.oRequests[action].abort) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import _ from '_';
|
import _ from '_';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { settingsSaveHelperSimpleFunction, defautOptionsAfterRender, inArray, trim, boolToAjax } from 'Common/Utils';
|
import { settingsSaveHelperSimpleFunction, defautOptionsAfterRender, trim, boolToAjax } from 'Common/Utils';
|
||||||
|
|
||||||
import { SaveSettingsStep, StorageResultType, Magics } from 'Common/Enums';
|
import { SaveSettingsStep, StorageResultType, Magics } from 'Common/Enums';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
|
|
@ -49,7 +49,7 @@ class ContactsAdminSettings {
|
||||||
this.contactsTypes = ko.observableArray([]);
|
this.contactsTypes = ko.observableArray([]);
|
||||||
this.contactsTypesOptions = ko.computed(() =>
|
this.contactsTypesOptions = ko.computed(() =>
|
||||||
_.map(this.contactsTypes(), (value) => {
|
_.map(this.contactsTypes(), (value) => {
|
||||||
const disabled = -1 === inArray(value, supportedTypes);
|
const disabled = supportedTypes.includes(value);
|
||||||
return {
|
return {
|
||||||
'id': value,
|
'id': value,
|
||||||
'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
|
'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
|
||||||
|
|
@ -66,7 +66,7 @@ class ContactsAdminSettings {
|
||||||
read: this.contactsType,
|
read: this.contactsType,
|
||||||
write: (value) => {
|
write: (value) => {
|
||||||
if (value !== this.contactsType()) {
|
if (value !== this.contactsType()) {
|
||||||
if (-1 < inArray(value, supportedTypes)) {
|
if (supportedTypes.includes(value)) {
|
||||||
this.contactsType(value);
|
this.contactsType(value);
|
||||||
} else if (0 < supportedTypes.length) {
|
} else if (0 < supportedTypes.length) {
|
||||||
this.contactsType('');
|
this.contactsType('');
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import window from 'window';
|
import window from 'window';
|
||||||
import { isUnd, isNormal, isArray, inArray } from 'Common/Utils';
|
import { isUnd, isNormal, isArray } from 'Common/Utils';
|
||||||
|
|
||||||
let SETTINGS = window.__rlah_data() || null;
|
let SETTINGS = window.__rlah_data() || null;
|
||||||
SETTINGS = isNormal(SETTINGS) ? SETTINGS : {};
|
SETTINGS = isNormal(SETTINGS) ? SETTINGS : {};
|
||||||
|
|
@ -37,5 +37,5 @@ export function appSettingsGet(name) {
|
||||||
*/
|
*/
|
||||||
export function capa(name) {
|
export function capa(name) {
|
||||||
const values = settingsGet('Capa');
|
const values = settingsGet('Capa');
|
||||||
return isArray(values) && isNormal(name) && -1 < inArray(name, values);
|
return isArray(values) && isNormal(name) && values.includes(name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import {
|
||||||
trim,
|
trim,
|
||||||
isNormal,
|
isNormal,
|
||||||
isArray,
|
isArray,
|
||||||
inArray,
|
|
||||||
pInt,
|
pInt,
|
||||||
pString,
|
pString,
|
||||||
plainToHtml,
|
plainToHtml,
|
||||||
|
|
@ -308,7 +307,7 @@ class MessageUserStore {
|
||||||
currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(),
|
currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(),
|
||||||
messages =
|
messages =
|
||||||
currentFolderFullNameRaw === fromFolderFullNameRaw
|
currentFolderFullNameRaw === fromFolderFullNameRaw
|
||||||
? _.filter(messageList, (item) => item && -1 < inArray(pInt(item.uid), uidForRemove))
|
? _.filter(messageList, (item) => item && uidForRemove.includes(pInt(item.uid)))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
_.each(messages, (item) => {
|
_.each(messages, (item) => {
|
||||||
|
|
@ -499,7 +498,7 @@ class MessageUserStore {
|
||||||
message.folderFullNameRaw === data.Result.Folder
|
message.folderFullNameRaw === data.Result.Folder
|
||||||
) {
|
) {
|
||||||
const threads = message.threads();
|
const threads = message.threads();
|
||||||
if (message.uid !== data.Result.Uid && 1 < threads.length && -1 < inArray(data.Result.Uid, threads)) {
|
if (message.uid !== data.Result.Uid && 1 < threads.length && threads.includes(data.Result.Uid)) {
|
||||||
message = MessageModel.newInstanceFromJson(data.Result);
|
message = MessageModel.newInstanceFromJson(data.Result);
|
||||||
if (message) {
|
if (message) {
|
||||||
message.threads(threads);
|
message.threads(threads);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import $ from '$';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import key from 'key';
|
import key from 'key';
|
||||||
|
|
||||||
import { inArray, pString, log, isUnd, trim, defautOptionsAfterRender } from 'Common/Utils';
|
import { pString, log, isUnd, trim, defautOptionsAfterRender } from 'Common/Utils';
|
||||||
|
|
||||||
import { Magics, KeyState } from 'Common/Enums';
|
import { Magics, KeyState } from 'Common/Enums';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
|
|
@ -64,7 +64,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
||||||
|
|
||||||
this.publicKeysOptions = ko.computed(() => {
|
this.publicKeysOptions = ko.computed(() => {
|
||||||
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
||||||
if (-1 < inArray(oKey, this.encryptKeysView())) {
|
if (this.encryptKeysView().includes(oKey)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _.map(oKey.users, (user) => ({
|
return _.map(oKey.users, (user) => ({
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import {
|
||||||
import {
|
import {
|
||||||
delegateRunOnDestroy,
|
delegateRunOnDestroy,
|
||||||
computedPagenatorHelper,
|
computedPagenatorHelper,
|
||||||
inArray,
|
|
||||||
trim,
|
trim,
|
||||||
windowResizeCallback,
|
windowResizeCallback,
|
||||||
isNonEmptyArray,
|
isNonEmptyArray,
|
||||||
|
|
@ -101,11 +100,11 @@ class ContactsPopupView extends AbstractViewNext {
|
||||||
this.viewPropertiesNames = ko.computed(() =>
|
this.viewPropertiesNames = ko.computed(() =>
|
||||||
_.filter(
|
_.filter(
|
||||||
this.viewProperties(),
|
this.viewProperties(),
|
||||||
(property) => -1 < inArray(property.type(), [ContactPropertyType.FirstName, ContactPropertyType.LastName])
|
(property) => [ContactPropertyType.FirstName, ContactPropertyType.LastName].includes(property.type())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.viewPropertiesOther = ko.computed(() =>
|
this.viewPropertiesOther = ko.computed(() =>
|
||||||
_.filter(this.viewProperties(), (property) => -1 < inArray(property.type(), [ContactPropertyType.Nick]))
|
_.filter(this.viewProperties(), (property) => [ContactPropertyType.Nick].includes(property.type()))
|
||||||
);
|
);
|
||||||
|
|
||||||
this.viewPropertiesEmails = ko.computed(() =>
|
this.viewPropertiesEmails = ko.computed(() =>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
Notification
|
Notification
|
||||||
} from 'Common/Enums';
|
} from 'Common/Enums';
|
||||||
|
|
||||||
import { trim, inArray, convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
|
import { trim, convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
|
||||||
|
|
||||||
import { $win } from 'Common/Globals';
|
import { $win } from 'Common/Globals';
|
||||||
import { getNotification, getNotificationFromResponse, reload as translatorReload } from 'Common/Translator';
|
import { getNotification, getNotificationFromResponse, reload as translatorReload } from 'Common/Translator';
|
||||||
|
|
@ -225,7 +225,7 @@ class LoginUserView extends AbstractViewNext {
|
||||||
}
|
}
|
||||||
} else if (oData.ErrorCode) {
|
} else if (oData.ErrorCode) {
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
if (-1 < inArray(oData.ErrorCode, [Notification.InvalidInputArgument])) {
|
if ([Notification.InvalidInputArgument].includes(oData.ErrorCode)) {
|
||||||
oData.ErrorCode = Notification.AuthError;
|
oData.ErrorCode = Notification.AuthError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class FolderListMailBoxUserView extends AbstractViewNext {
|
||||||
() =>
|
() =>
|
||||||
FolderStore.currentFolder() &&
|
FolderStore.currentFolder() &&
|
||||||
FolderStore.currentFolder().isInbox() &&
|
FolderStore.currentFolder().isInbox() &&
|
||||||
-1 < trim(MessageStore.messageListSearch()).indexOf('is:flagged')
|
trim(MessageStore.messageListSearch()).includes('is:flagged')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||||
|
|
||||||
import { bMobileDevice, popupVisibility, leftPanelDisabled, moveAction } from 'Common/Globals';
|
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 { mailBox, append } from 'Common/Links';
|
||||||
import { Selector } from 'Common/Selector';
|
import { Selector } from 'Common/Selector';
|
||||||
|
|
@ -653,7 +653,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
const checked = this.messageListCheckedOrSelected();
|
const checked = this.messageListCheckedOrSelected();
|
||||||
if (currentMessage) {
|
if (currentMessage) {
|
||||||
const checkedUids = _.map(checked, (message) => message.uid);
|
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(
|
this.setAction(
|
||||||
currentMessage.folderFullNameRaw,
|
currentMessage.folderFullNameRaw,
|
||||||
currentMessage.flagged() ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
currentMessage.flagged() ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import {
|
||||||
import { $htmlCL, leftPanelDisabled, keyScopeReal, useKeyboardShortcuts, moveAction } from 'Common/Globals';
|
import { $htmlCL, leftPanelDisabled, keyScopeReal, useKeyboardShortcuts, moveAction } from 'Common/Globals';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
inArray,
|
|
||||||
isNonEmptyArray,
|
isNonEmptyArray,
|
||||||
trim,
|
trim,
|
||||||
noop,
|
noop,
|
||||||
|
|
@ -135,7 +134,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.downloadAsZipAllowed = ko.computed(
|
this.downloadAsZipAllowed = ko.computed(
|
||||||
() => -1 < inArray('zip', this.attachmentsActions()) && this.allowAttachmnetControls()
|
() => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.downloadAsZipLoading = ko.observable(false);
|
this.downloadAsZipLoading = ko.observable(false);
|
||||||
|
|
@ -156,7 +155,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
read: this.lastReplyAction_,
|
read: this.lastReplyAction_,
|
||||||
write: (value) => {
|
write: (value) => {
|
||||||
this.lastReplyAction_(
|
this.lastReplyAction_(
|
||||||
-1 === inArray(value, [ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward])
|
[ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value)
|
||||||
? ComposeType.Reply
|
? ComposeType.Reply
|
||||||
: value
|
: value
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue