diff --git a/dev/Common/Selector.js b/dev/Common/Selector.js index 95f329dcd..7d01c2c52 100644 --- a/dev/Common/Selector.js +++ b/dev/Common/Selector.js @@ -146,7 +146,7 @@ class Selector { if (0 < len && aCheckedCache.includes(uid)) { isChecked = true; item.checked(true); - len -= 1; + --len; } if (!isChecked && null !== mSelected && mSelected === uid) { diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index a9f2fe4cf..370fcdadf 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -418,7 +418,7 @@ export function htmlToPlain(html) { limit = 800; while (0 < limit) { - limit -= 1; + --limit; iP1 = text.indexOf('__bq__start__', pos); if (-1 < iP1) { iP2 = text.indexOf('__bq__start__', iP1 + 5); @@ -778,17 +778,17 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount) { } while (0 < limit) { - prev -= 1; - next += 1; + --prev; + ++next; if (0 < prev) { fAdd(prev, false); - limit -= 1; + --limit; } if (pageCount >= next) { fAdd(next, true); - limit -= 1; + --limit; } else if (0 >= prev) { break; } diff --git a/dev/Model/Message.js b/dev/Model/Message.js index b91ea003b..9d7b724d0 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -209,27 +209,36 @@ class MessageModel extends AbstractModel { ); } + setFromJson(json) { + if (json && 'Object/Message' === json['@Object']) { + let priority = pInt(json.Priority); + this.priority( + [MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal + ); + + this.proxy = !!json.ExternalProxy; + + this.hasAttachments(!!json.HasAttachments); + this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); + + return true; + } + + return false; + } + /** * @param {AjaxJsonMessage} json * @returns {boolean} */ initByJson(json) { - let result = false, - priority = MessagePriority.Normal; - - if (json && 'Object/Message' === json['@Object']) { - priority = pInt(json.Priority); - this.priority( - [MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal - ); - + let result = this.setFromJson(json); + if (result) { this.folderFullNameRaw = json.Folder; this.uid = json.Uid; this.hash = json.Hash; this.requestHash = json.RequestHash; - this.proxy = !!json.ExternalProxy; - this.size(pInt(json.Size)); this.from = EmailCollectionModel.reviveFromJson(json.From); @@ -250,8 +259,6 @@ class MessageModel extends AbstractModel { } this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC)); - this.hasAttachments(!!json.HasAttachments); - this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); this.fromEmailString(this.from.toString(true)); this.fromClearEmailString(this.from.toStringClear()); @@ -262,8 +269,6 @@ class MessageModel extends AbstractModel { this.initFlagsByJson(json); this.computeSenderEmail(); - - result = true; } return result; @@ -274,41 +279,27 @@ class MessageModel extends AbstractModel { * @returns {boolean} */ initUpdateByMessageJson(json) { - let result = false, - priority = MessagePriority.Normal; - - if (json && 'Object/Message' === json['@Object']) { - priority = pInt(json.Priority); - this.priority( - [MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal - ); - + let result = this.setFromJson(json); + if (result) { this.aDraftInfo = json.DraftInfo; this.sMessageId = json.MessageId; this.sInReplyTo = json.InReplyTo; this.sReferences = json.References; - this.proxy = !!json.ExternalProxy; - if (PgpStore.capaOpenPGP()) { this.isPgpSigned(!!json.PgpSigned); this.isPgpEncrypted(!!json.PgpEncrypted); } - this.hasAttachments(!!json.HasAttachments); - this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []); - - this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : []; - this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundedCIDs)); +// this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : []; +// this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundedCIDs)); + this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments)); this.readReceipt(json.ReadReceipt || ''); this.computeSenderEmail(); - - result = true; } - return result; } diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 9c6911f70..3191ac013 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -154,11 +154,9 @@ class MessageUserStore { return selectedMessage ? checked.concat([selectedMessage]).filter((value, index, self) => self.indexOf(value) == index) : checked; - } else if (selectedMessage) { - return [selectedMessage]; } - return focusedMessage ? [focusedMessage] : []; + return selectedMessage ? [selectedMessage] : (focusedMessage ? [focusedMessage] : []); }); this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(() => { @@ -298,7 +296,7 @@ class MessageUserStore { messages.forEach(item => { if (item && item.unseen()) { - unseenCount += 1; + ++unseenCount; } }); @@ -488,8 +486,7 @@ class MessageUserStore { const textBody = document.getElementById(id); if (textBody) { - iMessageBodyCacheCount += 1; - textBody.rlCacheCount = iMessageBodyCacheCount; + textBody.rlCacheCount = ++iMessageBodyCacheCount; message.fetchDataFromDom(); message.body = textBody; } else { @@ -532,13 +529,11 @@ class MessageUserStore { resultHtml = '
' + resultHtml + ''; } - iMessageBodyCacheCount += 1; - body = Element.fromHTML('