mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 23:47:03 +03:00
Merge some parts of initByJson and initUpdateByMessageJson
Cleanup messageListChecked handling
This commit is contained in:
parent
46198861bc
commit
b66e68a3b1
8 changed files with 46 additions and 61 deletions
|
|
@ -146,7 +146,7 @@ class Selector {
|
||||||
if (0 < len && aCheckedCache.includes(uid)) {
|
if (0 < len && aCheckedCache.includes(uid)) {
|
||||||
isChecked = true;
|
isChecked = true;
|
||||||
item.checked(true);
|
item.checked(true);
|
||||||
len -= 1;
|
--len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChecked && null !== mSelected && mSelected === uid) {
|
if (!isChecked && null !== mSelected && mSelected === uid) {
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ export function htmlToPlain(html) {
|
||||||
limit = 800;
|
limit = 800;
|
||||||
|
|
||||||
while (0 < limit) {
|
while (0 < limit) {
|
||||||
limit -= 1;
|
--limit;
|
||||||
iP1 = text.indexOf('__bq__start__', pos);
|
iP1 = text.indexOf('__bq__start__', pos);
|
||||||
if (-1 < iP1) {
|
if (-1 < iP1) {
|
||||||
iP2 = text.indexOf('__bq__start__', iP1 + 5);
|
iP2 = text.indexOf('__bq__start__', iP1 + 5);
|
||||||
|
|
@ -778,17 +778,17 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (0 < limit) {
|
while (0 < limit) {
|
||||||
prev -= 1;
|
--prev;
|
||||||
next += 1;
|
++next;
|
||||||
|
|
||||||
if (0 < prev) {
|
if (0 < prev) {
|
||||||
fAdd(prev, false);
|
fAdd(prev, false);
|
||||||
limit -= 1;
|
--limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageCount >= next) {
|
if (pageCount >= next) {
|
||||||
fAdd(next, true);
|
fAdd(next, true);
|
||||||
limit -= 1;
|
--limit;
|
||||||
} else if (0 >= prev) {
|
} else if (0 >= prev) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
* @param {AjaxJsonMessage} json
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
initByJson(json) {
|
initByJson(json) {
|
||||||
let result = false,
|
let result = this.setFromJson(json);
|
||||||
priority = MessagePriority.Normal;
|
if (result) {
|
||||||
|
|
||||||
if (json && 'Object/Message' === json['@Object']) {
|
|
||||||
priority = pInt(json.Priority);
|
|
||||||
this.priority(
|
|
||||||
[MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal
|
|
||||||
);
|
|
||||||
|
|
||||||
this.folderFullNameRaw = json.Folder;
|
this.folderFullNameRaw = json.Folder;
|
||||||
this.uid = json.Uid;
|
this.uid = json.Uid;
|
||||||
this.hash = json.Hash;
|
this.hash = json.Hash;
|
||||||
this.requestHash = json.RequestHash;
|
this.requestHash = json.RequestHash;
|
||||||
|
|
||||||
this.proxy = !!json.ExternalProxy;
|
|
||||||
|
|
||||||
this.size(pInt(json.Size));
|
this.size(pInt(json.Size));
|
||||||
|
|
||||||
this.from = EmailCollectionModel.reviveFromJson(json.From);
|
this.from = EmailCollectionModel.reviveFromJson(json.From);
|
||||||
|
|
@ -250,8 +259,6 @@ class MessageModel extends AbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC));
|
this.dateTimeStampInUTC(pInt(json.DateTimeStampInUTC));
|
||||||
this.hasAttachments(!!json.HasAttachments);
|
|
||||||
this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
|
||||||
|
|
||||||
this.fromEmailString(this.from.toString(true));
|
this.fromEmailString(this.from.toString(true));
|
||||||
this.fromClearEmailString(this.from.toStringClear());
|
this.fromClearEmailString(this.from.toStringClear());
|
||||||
|
|
@ -262,8 +269,6 @@ class MessageModel extends AbstractModel {
|
||||||
|
|
||||||
this.initFlagsByJson(json);
|
this.initFlagsByJson(json);
|
||||||
this.computeSenderEmail();
|
this.computeSenderEmail();
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -274,41 +279,27 @@ class MessageModel extends AbstractModel {
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
initUpdateByMessageJson(json) {
|
initUpdateByMessageJson(json) {
|
||||||
let result = false,
|
let result = this.setFromJson(json);
|
||||||
priority = MessagePriority.Normal;
|
if (result) {
|
||||||
|
|
||||||
if (json && 'Object/Message' === json['@Object']) {
|
|
||||||
priority = pInt(json.Priority);
|
|
||||||
this.priority(
|
|
||||||
[MessagePriority.High, MessagePriority.Low].includes(priority) ? priority : MessagePriority.Normal
|
|
||||||
);
|
|
||||||
|
|
||||||
this.aDraftInfo = json.DraftInfo;
|
this.aDraftInfo = json.DraftInfo;
|
||||||
|
|
||||||
this.sMessageId = json.MessageId;
|
this.sMessageId = json.MessageId;
|
||||||
this.sInReplyTo = json.InReplyTo;
|
this.sInReplyTo = json.InReplyTo;
|
||||||
this.sReferences = json.References;
|
this.sReferences = json.References;
|
||||||
|
|
||||||
this.proxy = !!json.ExternalProxy;
|
|
||||||
|
|
||||||
if (PgpStore.capaOpenPGP()) {
|
if (PgpStore.capaOpenPGP()) {
|
||||||
this.isPgpSigned(!!json.PgpSigned);
|
this.isPgpSigned(!!json.PgpSigned);
|
||||||
this.isPgpEncrypted(!!json.PgpEncrypted);
|
this.isPgpEncrypted(!!json.PgpEncrypted);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasAttachments(!!json.HasAttachments);
|
// this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : [];
|
||||||
this.attachmentsSpecData(isArray(json.AttachmentsSpecData) ? json.AttachmentsSpecData : []);
|
// this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundedCIDs));
|
||||||
|
this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments));
|
||||||
this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : [];
|
|
||||||
this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundedCIDs));
|
|
||||||
|
|
||||||
this.readReceipt(json.ReadReceipt || '');
|
this.readReceipt(json.ReadReceipt || '');
|
||||||
|
|
||||||
this.computeSenderEmail();
|
this.computeSenderEmail();
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,9 @@ class MessageUserStore {
|
||||||
return selectedMessage
|
return selectedMessage
|
||||||
? checked.concat([selectedMessage]).filter((value, index, self) => self.indexOf(value) == index)
|
? checked.concat([selectedMessage]).filter((value, index, self) => self.indexOf(value) == index)
|
||||||
: checked;
|
: checked;
|
||||||
} else if (selectedMessage) {
|
|
||||||
return [selectedMessage];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return focusedMessage ? [focusedMessage] : [];
|
return selectedMessage ? [selectedMessage] : (focusedMessage ? [focusedMessage] : []);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(() => {
|
this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(() => {
|
||||||
|
|
@ -298,7 +296,7 @@ class MessageUserStore {
|
||||||
|
|
||||||
messages.forEach(item => {
|
messages.forEach(item => {
|
||||||
if (item && item.unseen()) {
|
if (item && item.unseen()) {
|
||||||
unseenCount += 1;
|
++unseenCount;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -488,8 +486,7 @@ class MessageUserStore {
|
||||||
|
|
||||||
const textBody = document.getElementById(id);
|
const textBody = document.getElementById(id);
|
||||||
if (textBody) {
|
if (textBody) {
|
||||||
iMessageBodyCacheCount += 1;
|
textBody.rlCacheCount = ++iMessageBodyCacheCount;
|
||||||
textBody.rlCacheCount = iMessageBodyCacheCount;
|
|
||||||
message.fetchDataFromDom();
|
message.fetchDataFromDom();
|
||||||
message.body = textBody;
|
message.body = textBody;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -532,13 +529,11 @@ class MessageUserStore {
|
||||||
resultHtml = '<pre>' + resultHtml + '</pre>';
|
resultHtml = '<pre>' + resultHtml + '</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
iMessageBodyCacheCount += 1;
|
|
||||||
|
|
||||||
body = Element.fromHTML('<div id="' + id + '" hidden="" class="rl-cache-class b-text-part '
|
body = Element.fromHTML('<div id="' + id + '" hidden="" class="rl-cache-class b-text-part '
|
||||||
+ (isHtml ? 'html' : 'plain') + '">'
|
+ (isHtml ? 'html' : 'plain') + '">'
|
||||||
+ findEmailAndLinks(resultHtml)
|
+ findEmailAndLinks(resultHtml)
|
||||||
+ '</div>');
|
+ '</div>');
|
||||||
body.rlCacheCount = iMessageBodyCacheCount;
|
body.rlCacheCount = ++iMessageBodyCacheCount;
|
||||||
|
|
||||||
// Drop Microsoft Office style properties
|
// Drop Microsoft Office style properties
|
||||||
const rgbRE = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/g,
|
const rgbRE = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/g,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count -= 1;
|
--count;
|
||||||
done = false;
|
done = false;
|
||||||
} else {
|
} else {
|
||||||
done = true;
|
done = true;
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,7 @@ class ContactsPopupView extends AbstractViewNext {
|
||||||
}
|
}
|
||||||
|
|
||||||
contact.deleted(true);
|
contact.deleted(true);
|
||||||
count -= 1;
|
--count;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (0 >= count) {
|
if (0 >= count) {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
this.messageListEndFolder = MessageStore.messageListEndFolder;
|
this.messageListEndFolder = MessageStore.messageListEndFolder;
|
||||||
this.messageListEndThreadUid = MessageStore.messageListEndThreadUid;
|
this.messageListEndThreadUid = MessageStore.messageListEndThreadUid;
|
||||||
|
|
||||||
this.messageListChecked = MessageStore.messageListChecked;
|
|
||||||
this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected;
|
this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected;
|
||||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
|
this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
|
||||||
this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle;
|
this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle;
|
||||||
|
|
@ -195,11 +194,10 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
() => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
() => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.mobileCheckedStateShow = ko.computed(() => {
|
// this.messageListChecked = MessageStore.messageListChecked;
|
||||||
return this.mobile ? 0 < this.messageListChecked().length : true;
|
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());
|
this.messageListFocused = ko.computed(() => Focused.MessageList === AppStore.focusedState());
|
||||||
|
|
||||||
|
|
@ -376,7 +374,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
}
|
}
|
||||||
|
|
||||||
goToUpUpOrDownDown(up) {
|
goToUpUpOrDownDown(up) {
|
||||||
if (this.messageListChecked().length) {
|
if (MessageStore.messageListChecked().length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,6 +486,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
dragImage || (dragImage = document.getElementById('messagesDragImage'));
|
dragImage || (dragImage = document.getElementById('messagesDragImage'));
|
||||||
|
|
||||||
const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails();
|
const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails();
|
||||||
|
item && !uids.includes(item.uid) && uids.push(item.uid);
|
||||||
if (dragImage && uids.length) {
|
if (dragImage && uids.length) {
|
||||||
dragImage.querySelector('.text').textContent = uids.length;
|
dragImage.querySelector('.text').textContent = uids.length;
|
||||||
let img = dragImage.querySelector('.icon-white');
|
let img = dragImage.querySelector('.icon-white');
|
||||||
|
|
@ -544,7 +543,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
if (folder) {
|
if (folder) {
|
||||||
MessageStore.messageList().forEach(message => {
|
MessageStore.messageList().forEach(message => {
|
||||||
if (message.unseen()) {
|
if (message.unseen()) {
|
||||||
cnt += 1;
|
++cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.unseen(false);
|
message.unseen(false);
|
||||||
|
|
@ -570,7 +569,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
if (folder) {
|
if (folder) {
|
||||||
MessageStore.messageList().forEach(message => {
|
MessageStore.messageList().forEach(message => {
|
||||||
if (!message.unseen()) {
|
if (!message.unseen()) {
|
||||||
cnt += 1;
|
++cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.unseen(true);
|
message.unseen(true);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
this.attachmentsActions = AppStore.attachmentsActions;
|
this.attachmentsActions = AppStore.attachmentsActions;
|
||||||
|
|
||||||
this.message = MessageStore.message;
|
this.message = MessageStore.message;
|
||||||
this.messageListChecked = MessageStore.messageListChecked;
|
// this.messageListChecked = MessageStore.messageListChecked;
|
||||||
this.hasCheckedMessages = MessageStore.hasCheckedMessages;
|
this.hasCheckedMessages = MessageStore.hasCheckedMessages;
|
||||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
|
this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
|
||||||
this.messageLoadingThrottle = MessageStore.messageLoadingThrottle;
|
this.messageLoadingThrottle = MessageStore.messageLoadingThrottle;
|
||||||
|
|
@ -410,7 +410,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
index = listIndex;
|
index = listIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
listIndex += 1;
|
++listIndex;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
src: item.linkPreview(),
|
src: item.linkPreview(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue