Speedup message bodies cache cleanup

Remove ko.bindingHandlers.link
This commit is contained in:
djmaze 2021-02-10 16:50:58 +01:00
parent 15631427b0
commit 111455054e
3 changed files with 13 additions and 29 deletions

View file

@ -217,10 +217,6 @@ ko.bindingHandlers.sortableItem = {
}
};
ko.bindingHandlers.link = {
update: (element, fValueAccessor) => element.href = ko.unwrap(fValueAccessor())
};
ko.bindingHandlers.initDom = {
init: (element, fValueAccessor) => fValueAccessor()(element)
};

View file

@ -49,8 +49,6 @@ const
.replace(email, '$1<a href="mailto:$2">$2</a>'),
isChecked = item => item.checked();
let iMessageBodyCacheCount = 0;
doc.body.append(hcont);
class MessageUserStore {
@ -89,6 +87,7 @@ class MessageUserStore {
messageFullScreenMode: false,
// Cache mail bodies
messagesBodiesDom: null,
messageActiveDom: null
});
@ -234,21 +233,11 @@ class MessageUserStore {
}
purgeMessageBodyCache() {
const end = iMessageBodyCacheCount - 15;
if (0 < end) {
let count = 0;
const messagesDom = this.messagesBodiesDom();
if (messagesDom) {
messagesDom.querySelectorAll('.rl-cache-class').forEach(node => {
if (end > node.rlCacheCount) {
node.classList.add('rl-cache-purge');
++count;
}
});
if (0 < count) {
setTimeout(() => messagesDom.querySelectorAll('.rl-cache-purge').forEach(node => node.remove()), 350);
}
const messagesDom = this.messagesBodiesDom(),
children = messagesDom && messagesDom.children;
if (children) {
while (15 < children.length) {
children[0].remove();
}
}
}
@ -286,7 +275,7 @@ class MessageUserStore {
hideMessageBodies() {
const messagesDom = this.messagesBodiesDom();
messagesDom && messagesDom.querySelectorAll('.b-text-part').forEach(el => el.hidden = true);
messagesDom && Array.from(messagesDom.children).forEach(el => el.hidden = true);
}
/**
@ -506,9 +495,9 @@ class MessageUserStore {
const textBody = doc.getElementById(id);
if (textBody) {
textBody.rlCacheCount = ++iMessageBodyCacheCount;
message.body = textBody;
message.fetchDataFromDom();
messagesDom.append(textBody);
} else {
let isHtml = false;
if (json.Html) {
@ -549,11 +538,10 @@ class MessageUserStore {
resultHtml = '<pre>' + resultHtml + '</pre>';
}
body = Element.fromHTML('<div id="' + id + '" hidden="" class="rl-cache-class b-text-part '
body = Element.fromHTML('<div id="' + id + '" hidden="" class="b-text-part '
+ (isHtml ? 'html' : 'plain') + '">'
+ findEmailAndLinks(resultHtml)
+ '</div>');
body.rlCacheCount = ++iMessageBodyCacheCount;
// Drop Microsoft Office style properties
const rgbRE = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/g,

View file

@ -135,7 +135,7 @@
</a>
</li>
<li class="e-item" role="presentation" data-bind="visible: message() && message().hasUnsubsribeLinks()">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="link: viewUnsubscribeLink()">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="attr: { href: viewUnsubscribeLink }">
<i class="fontastic"></i>
<span class="i18n" data-i18n="MESSAGE/BUTTON_UNSUBSCRIBE"></span>
</a>
@ -155,13 +155,13 @@
</a>
</li>
<li class="e-item dividerbar" role="presentation">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="link: viewViewLink()">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="attr: { href: viewViewLink }">
<i class="icon-file-code"></i>
<span class="i18n" data-i18n="MESSAGE/MENU_VIEW_ORIGINAL"></span>
</a>
</li>
<li class="e-item" role="presentation">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="link: viewDownloadLink()">
<a target="_blank" class="e-link menuitem" href="#" tabindex="-1" data-bind="attr: { href: viewDownloadLink }">
<i class="icon-download"></i>
<span class="i18n" data-i18n="MESSAGE/MENU_DOWNLOAD_ORIGINAL"></span>
</a>
@ -360,7 +360,7 @@
</div>
</div>
<div class="bodyText g-ui-min-height-300 rl-mv-root"
<div class="bodyText g-ui-min-height-300"
data-bind="initDom: messagesBodiesDom"></div>
</div>
</div>