mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Message whitelist #201:
* sort options based on domain count (highest top) * hide when whitelist not active
This commit is contained in:
parent
e12eeeafc6
commit
85d3a95dec
3 changed files with 20 additions and 6 deletions
|
|
@ -156,12 +156,24 @@ export class MessageModel extends AbstractModel {
|
||||||
let options = [];
|
let options = [];
|
||||||
if ('match' === SettingsUserStore.viewImages()) {
|
if ('match' === SettingsUserStore.viewImages()) {
|
||||||
let from = this.from[0],
|
let from = this.from[0],
|
||||||
list = SettingsUserStore.viewImagesWhitelist();
|
list = SettingsUserStore.viewImagesWhitelist(),
|
||||||
from && options.push(from.email);
|
counts = {};
|
||||||
this.html().match(/src=["'][^"']+/g)?.forEach(m => options.push(m.replace(/^.+(:\/\/[^/]+).+$/, '$1')));
|
this.html().match(/src=["'][^"']+/g)?.forEach(m => {
|
||||||
options = options.filter(txt => !list.includes(txt));
|
m = m.replace(/^.+(:\/\/[^/]+).+$/, '$1');
|
||||||
|
if (counts[m]) {
|
||||||
|
++counts[m];
|
||||||
|
} else {
|
||||||
|
counts[m] = 1;
|
||||||
|
options.push(m);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
options = options.filter(txt => !list.includes(txt)).sort((a,b) => (counts[a] < counts[b])
|
||||||
|
? 1
|
||||||
|
: (counts[a] > counts[b] ? -1 : a.localeCompare(b))
|
||||||
|
);
|
||||||
|
from && options.unshift(from.email);
|
||||||
}
|
}
|
||||||
return options.unique();
|
return options;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,8 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showWhitelistOptions: () => 'match' === SettingsUserStore.viewImages(),
|
||||||
|
|
||||||
firstUnsubsribeLink: () => currentMessage()?.unsubsribeLinks()[0] || '',
|
firstUnsubsribeLink: () => currentMessage()?.unsubsribeLinks()[0] || '',
|
||||||
|
|
||||||
pgpSupported: () => currentMessage() && PgpUserStore.isSupported(),
|
pgpSupported: () => currentMessage() && PgpUserStore.isSupported(),
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@
|
||||||
|
|
||||||
<div class="showImages" data-bind="visible: message().hasImages()">
|
<div class="showImages" data-bind="visible: message().hasImages()">
|
||||||
<div class="btn" data-bind="click: showImages" data-icon="🖼" data-i18n="MESSAGE/BUTTON_SHOW_IMAGES"></div>
|
<div class="btn" data-bind="click: showImages" data-icon="🖼" data-i18n="MESSAGE/BUTTON_SHOW_IMAGES"></div>
|
||||||
<div class="btn-group" data-bind="registerBootstrapDropdown: true" style="display: inline-block">
|
<div class="btn-group" data-bind="registerBootstrapDropdown: true, visible: showWhitelistOptions" style="display: inline-block">
|
||||||
<a class="btn dropdown-toggle" id="whitelist-dropdown-id" data-icon="🖼" href="#" tabindex="-1"><span data-i18n="SETTINGS_GENERAL/IMAGES_WHITELIST"></span> ▼</a>
|
<a class="btn dropdown-toggle" id="whitelist-dropdown-id" data-icon="🖼" href="#" tabindex="-1"><span data-i18n="SETTINGS_GENERAL/IMAGES_WHITELIST"></span> ▼</a>
|
||||||
<menu class="dropdown-menu right-edge" role="menu" aria-labelledby="whitelist-dropdown-id">
|
<menu class="dropdown-menu right-edge" role="menu" aria-labelledby="whitelist-dropdown-id">
|
||||||
<!-- ko foreach: message().whitelistOptions() -->
|
<!-- ko foreach: message().whitelistOptions() -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue