Cleanup array.length checks and for() to forEach()

This commit is contained in:
djmaze 2020-07-28 12:35:41 +02:00
parent db5751cd00
commit 82bed1ed80
24 changed files with 135 additions and 169 deletions

View file

@ -144,7 +144,7 @@ class FilterModel extends AbstractModel {
return false;
}
if (0 < this.conditions().length) {
if (this.conditions().length) {
if (this.conditions().find(cond => cond && !cond.verify())) {
return false;
}

View file

@ -137,7 +137,7 @@ class FolderModel extends AbstractModel {
this.canBeDeleted = ko.computed(() => {
const bSystem = this.isSystemFolder();
return !bSystem && 0 === this.subFolders().length && inboxFolderName !== this.fullNameRaw;
return !bSystem && !this.subFolders().length && inboxFolderName !== this.fullNameRaw;
});
this.canBeSubScribed = ko.computed(

View file

@ -354,7 +354,6 @@ class MessageModel extends AbstractModel {
if (attachment) {
if (
'' !== attachment.cidWithOutTags &&
0 < this.foundedCIDs.length &&
this.foundedCIDs.includes(attachment.cidWithOutTags)
) {
attachment.isLinked = true;
@ -372,14 +371,14 @@ class MessageModel extends AbstractModel {
* @returns {boolean}
*/
hasUnsubsribeLinks() {
return this.unsubsribeLinks && 0 < this.unsubsribeLinks.length;
return this.unsubsribeLinks && this.unsubsribeLinks.length;
}
/**
* @returns {string}
*/
getFirstUnsubsribeLink() {
return this.unsubsribeLinks && 0 < this.unsubsribeLinks.length ? this.unsubsribeLinks[0] || '' : '';
return this.unsubsribeLinks && this.unsubsribeLinks.length ? this.unsubsribeLinks[0] || '' : '';
}
/**
@ -573,11 +572,11 @@ class MessageModel extends AbstractModel {
unic = isUnd(excludeEmails) ? {} : excludeEmails;
replyHelper(this.replyTo, unic, result);
if (0 === result.length) {
if (!result.length) {
replyHelper(this.from, unic, result);
}
if (0 === result.length && !last) {
if (!result.length && !last) {
return this.replyEmails({}, true);
}
@ -596,14 +595,14 @@ class MessageModel extends AbstractModel {
unic = isUnd(excludeEmails) ? {} : excludeEmails;
replyHelper(this.replyTo, unic, toResult);
if (0 === toResult.length) {
if (!toResult.length) {
replyHelper(this.from, unic, toResult);
}
replyHelper(this.to, unic, toResult);
replyHelper(this.cc, unic, ccResult);
if (0 === toResult.length && !last) {
if (!toResult.length && !last) {
data = this.replyAllEmails({}, true);
return [data[0], ccResult];
}
@ -623,7 +622,7 @@ class MessageModel extends AbstractModel {
*/
attachmentsToStringLine() {
const attachLines = this.attachments().map(item => item.fileName + ' (' + item.friendlySize + ')');
return attachLines && 0 < attachLines.length ? attachLines.join(', ') : '';
return attachLines && attachLines.length ? attachLines.join(', ') : '';
}
/**