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(''); - body.rlCacheCount = iMessageBodyCacheCount; + body.rlCacheCount = ++iMessageBodyCacheCount; // Drop Microsoft Office style properties const rgbRE = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/g, diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index 17a5fdde5..9d833604c 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -64,7 +64,7 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext { } } - count -= 1; + --count; done = false; } else { done = true; diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 62a1e4e43..ea5d76ae7 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -449,7 +449,7 @@ class ContactsPopupView extends AbstractViewNext { } contact.deleted(true); - count -= 1; + --count; }); if (0 >= count) { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 41a1670e3..75f65d902 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -98,7 +98,6 @@ class MessageListMailBoxUserView extends AbstractViewNext { this.messageListEndFolder = MessageStore.messageListEndFolder; this.messageListEndThreadUid = MessageStore.messageListEndThreadUid; - this.messageListChecked = MessageStore.messageListChecked; this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected; this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails; this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle; @@ -195,11 +194,10 @@ class MessageListMailBoxUserView extends AbstractViewNext { () => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder() ); - this.mobileCheckedStateShow = ko.computed(() => { - return this.mobile ? 0 < this.messageListChecked().length : true; - }); +// this.messageListChecked = MessageStore.messageListChecked; + this.mobileCheckedStateShow = ko.computed(() => this.mobile ? 0 < MessageStore.messageListChecked().length : true); - this.mobileCheckedStateHide = ko.computed(() => this.mobile ? !this.messageListChecked().length : true); + this.mobileCheckedStateHide = ko.computed(() => this.mobile ? !MessageStore.messageListChecked().length : true); this.messageListFocused = ko.computed(() => Focused.MessageList === AppStore.focusedState()); @@ -376,7 +374,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { } goToUpUpOrDownDown(up) { - if (this.messageListChecked().length) { + if (MessageStore.messageListChecked().length) { return false; } @@ -488,6 +486,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { dragImage || (dragImage = document.getElementById('messagesDragImage')); const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails(); + item && !uids.includes(item.uid) && uids.push(item.uid); if (dragImage && uids.length) { dragImage.querySelector('.text').textContent = uids.length; let img = dragImage.querySelector('.icon-white'); @@ -544,7 +543,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { if (folder) { MessageStore.messageList().forEach(message => { if (message.unseen()) { - cnt += 1; + ++cnt; } message.unseen(false); @@ -570,7 +569,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { if (folder) { MessageStore.messageList().forEach(message => { if (!message.unseen()) { - cnt += 1; + ++cnt; } message.unseen(true); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index a306fa915..6f83875de 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -92,7 +92,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { this.attachmentsActions = AppStore.attachmentsActions; this.message = MessageStore.message; - this.messageListChecked = MessageStore.messageListChecked; +// this.messageListChecked = MessageStore.messageListChecked; this.hasCheckedMessages = MessageStore.hasCheckedMessages; this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails; this.messageLoadingThrottle = MessageStore.messageLoadingThrottle; @@ -410,7 +410,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { index = listIndex; } - listIndex += 1; + ++listIndex; return { src: item.linkPreview(),