Merge Objects prototype extensions

This commit is contained in:
djmaze 2020-09-04 17:07:35 +02:00
parent 0647b5201f
commit f2d194947d
26 changed files with 108 additions and 127 deletions

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { FileType } from 'Common/Enums';
import { bMobileDevice } from 'Common/Globals';
import { pInt, isNonEmptyArray, getFileExtension, friendlySize } from 'Common/Utils';
import { pInt, getFileExtension, friendlySize } from 'Common/Utils';
import {
attachmentDownload,
attachmentPreview,
@ -149,7 +149,7 @@ export const staticCombinedIconClass = (data) => {
let result = '',
types = [];
if (isNonEmptyArray(data)) {
if (Array.isNotEmpty(data)) {
result = 'icon-attachment';
types = data.map(item => item ? staticFileType(getFileExtension(item[0]), item[1]) : '')
.filter((value, index, self) => !!value && self.indexOf(value) == index);

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { ContactPropertyType } from 'Common/Enums';
import { isNonEmptyArray, pInt, pString } from 'Common/Utils';
import { pInt, pString } from 'Common/Utils';
import { emptyContactPic } from 'Common/Links';
import { AbstractModel } from 'Knoin/AbstractModel';
@ -28,7 +28,7 @@ class ContactModel extends AbstractModel {
let name = '',
email = '';
if (isNonEmptyArray(this.properties)) {
if (Array.isNotEmpty(this.properties)) {
this.properties.forEach(property => {
if (property) {
if (ContactPropertyType.FirstName === property[0]) {
@ -56,7 +56,7 @@ class ContactModel extends AbstractModel {
this.display = pString(json.Display);
this.readOnly = !!json.ReadOnly;
if (isNonEmptyArray(json.Properties)) {
if (Array.isNotEmpty(json.Properties)) {
json.Properties.forEach(property => {
if (property && property.Type && null != property.Value && null != property.TypeStr) {
this.properties.push([pInt(property.Type), pString(property.Value), pString(property.TypeStr)]);

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { FilterRulesType, FiltersAction } from 'Common/Enums';
import { pString, isNonEmptyArray, fakeMd5, delegateRunOnDestroy } from 'Common/Utils';
import { pString, fakeMd5, delegateRunOnDestroy } from 'Common/Utils';
import { i18n } from 'Common/Translator';
import { getFolderFromCacheList } from 'Common/Cache';
@ -225,7 +225,7 @@ class FilterModel extends AbstractModel {
this.conditions([]);
if (isNonEmptyArray(json.Conditions)) {
if (Array.isNotEmpty(json.Conditions)) {
this.conditions(
json.Conditions.map(aData => {
const filterCondition = new FilterConditionModel();

View file

@ -7,8 +7,7 @@ import {
pInt,
deModule,
encodeHtml,
friendlySize,
isNonEmptyArray
friendlySize
} from 'Common/Utils';
import { messageViewLink, messageDownloadLink } from 'Common/Links';
@ -257,7 +256,7 @@ class MessageModel extends AbstractModel {
this.bcc = emailArrayFromJson(json.Bcc);
this.replyTo = emailArrayFromJson(json.ReplyTo);
this.deliveredTo = emailArrayFromJson(json.DeliveredTo);
this.unsubsribeLinks = isNonEmptyArray(json.UnsubsribeLinks) ? json.UnsubsribeLinks : [];
this.unsubsribeLinks = Array.isNotEmpty(json.UnsubsribeLinks) ? json.UnsubsribeLinks : [];
this.subject(json.Subject);
if (isArray(json.SubjectParts)) {
@ -341,7 +340,7 @@ class MessageModel extends AbstractModel {
attachment = null;
const result = [];
if (json && 'Collection/AttachmentCollection' === json['@Object'] && isNonEmptyArray(json['@Collection'])) {
if (json && 'Collection/AttachmentCollection' === json['@Object'] && Array.isNotEmpty(json['@Collection'])) {
for (index = 0, len = json['@Collection'].length; index < len; index++) {
attachment = AttachmentModel.newInstanceFromJson(json['@Collection'][index]);
if (attachment) {
@ -408,7 +407,7 @@ class MessageModel extends AbstractModel {
*/
fromDkimData() {
let result = ['none', ''];
if (isNonEmptyArray(this.from) && 1 === this.from.length && this.from[0] && this.from[0].dkimStatus) {
if (Array.isNotEmpty(this.from) && 1 === this.from.length && this.from[0] && this.from[0].dkimStatus) {
result = [this.from[0].dkimStatus, this.from[0].dkimValue || ''];
}
@ -492,7 +491,7 @@ class MessageModel extends AbstractModel {
let result = null;
const attachments = this.attachments();
if (isNonEmptyArray(attachments)) {
if (Array.isNotEmpty(attachments)) {
cid = cid.replace(/^<+/, '').replace(/>+$/, '');
result = attachments.find(item => cid === item.cidWithOutTags);
}
@ -508,7 +507,7 @@ class MessageModel extends AbstractModel {
let result = null;
const attachments = this.attachments();
if (isNonEmptyArray(attachments)) {
if (Array.isNotEmpty(attachments)) {
result = attachments.find(item => contentLocation === item.contentLocation);
}

View file

@ -1,7 +1,5 @@
import ko from 'ko';
import { isNonEmptyArray } from 'Common/Utils';
import { AbstractModel } from 'Knoin/AbstractModel';
import PgpStore from 'Stores/User/Pgp';
@ -23,7 +21,7 @@ class OpenPgpKeyModel extends AbstractModel {
this.index = index;
this.id = ID;
this.ids = isNonEmptyArray(IDs) ? IDs : [ID];
this.ids = Array.isNotEmpty(IDs) ? IDs : [ID];
this.guid = guID;
this.user = '';
this.users = userIDs;