mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-31 03:52:01 +08:00
Speedup message bodies cache cleanup
Remove ko.bindingHandlers.link
This commit is contained in:
parent
15631427b0
commit
111455054e
3 changed files with 13 additions and 29 deletions
4
dev/External/User/ko.js
vendored
4
dev/External/User/ko.js
vendored
|
@ -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)
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue