mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
Use jQuery.slim
Underscore.js _.uniq(_.compact( to native Array.filter((value, index, self) => !!value && self.indexOf(value) == index) Underscore.js _.compact to native Array.filter(value => !!value) Underscore.js _.uniq to native Array.filter((value, index, self) => self.indexOf(value) == index) Underscore.js _.values to native Object.values Underscore.js _.flatten to native Array.flat Underscore.js _.union to native Array.concat + unique filter Underscore.js _.reduce to native Array.reduce Underscore.js _.escape replaced with advanced htmlspecialchars() Underscore.js _.memoize replaced Now Underscore.js is a slim custom version (only _.debounce, _.defer & _.throttle)
This commit is contained in:
parent
996a71ad8a
commit
dca0ff02ed
27 changed files with 515 additions and 353 deletions
|
|
@ -600,13 +600,13 @@ class ComposePopupView extends AbstractViewNext {
|
|||
case ComposeType.ReplyAll:
|
||||
case ComposeType.Forward:
|
||||
case ComposeType.ForwardAsAttachment:
|
||||
_.union(message.to, message.cc, message.bcc).forEach(fEachHelper);
|
||||
message.to.concat(message.cc, message.bcc).forEach(fEachHelper);
|
||||
if (!resultIdentity) {
|
||||
message.deliveredTo.forEach(fEachHelper);
|
||||
}
|
||||
break;
|
||||
case ComposeType.Draft:
|
||||
_.union(message.from, message.replyTo).forEach(fEachHelper);
|
||||
message.from.concat(message.replyTo).forEach(fEachHelper);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
|
@ -859,7 +859,8 @@ class ComposePopupView extends AbstractViewNext {
|
|||
addEmailsTo(fKoValue, emails) {
|
||||
if (isNonEmptyArray(emails)) {
|
||||
const value = trim(fKoValue()),
|
||||
values = _.uniq(_.compact(emails.map(item => (item ? item.toLine(false) : null))));
|
||||
values = emails.map(item => item ? item.toLine(false) : null)
|
||||
.filter((value, index, self) => !!value && self.indexOf(value) == index);
|
||||
|
||||
fKoValue(value + ('' === value ? '' : ', ') + trim(values.join(', ')));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import key from 'key';
|
||||
|
|
@ -44,7 +43,9 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
|
||||
this.encryptKeysView = ko.computed(() => _.compact(this.encryptKeys().map(oKey => (oKey ? oKey.key : null))));
|
||||
this.encryptKeysView = ko.computed(
|
||||
() => this.encryptKeys().map(oKey => (oKey ? oKey.key : null)).filter(value => !!value)
|
||||
);
|
||||
|
||||
this.privateKeysOptions = ko.computed(() => {
|
||||
const opts = PgpStore.openpgpkeysPrivate().map((oKey, iIndex) => {
|
||||
|
|
@ -59,7 +60,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
}));
|
||||
});
|
||||
|
||||
return _.compact(_.flatten(opts, true));
|
||||
return opts.flat().filter(value => !!value);
|
||||
});
|
||||
|
||||
this.publicKeysOptions = ko.computed(() => {
|
||||
|
|
@ -74,7 +75,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
'class': index % 2 ? 'odd' : 'even'
|
||||
}));
|
||||
});
|
||||
return _.compact(_.flatten(opts, true));
|
||||
return opts.flat().filter(value => !!value);
|
||||
});
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
|
@ -159,7 +160,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
|
||||
this.encryptKeys().forEach(oKey => {
|
||||
if (oKey && oKey.key) {
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
aPublicKeys = aPublicKeys.concat(oKey.key.getNativeKeys().flat(Infinity).filter(value => !!value));
|
||||
} else if (oKey && oKey.email) {
|
||||
this.notification(
|
||||
i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
|
|
@ -355,13 +356,11 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
}
|
||||
|
||||
rec = rec.join(', ').split(',');
|
||||
rec = _.compact(
|
||||
rec.map(value => {
|
||||
rec = rec.map(value => {
|
||||
email.clear();
|
||||
email.parse(trim(value));
|
||||
return '' === email.email ? false : email.email;
|
||||
})
|
||||
);
|
||||
}).filter(value => !!value);
|
||||
|
||||
if (identity && identity.email()) {
|
||||
emailLine = identity.email();
|
||||
|
|
@ -383,28 +382,22 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
|
||||
if (rec && 0 < rec.length) {
|
||||
this.encryptKeys(
|
||||
_.uniq(
|
||||
_.compact(
|
||||
_.flatten(
|
||||
rec.map(recEmail => {
|
||||
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||
return keys
|
||||
? keys.map(publicKey => ({
|
||||
'empty': !publicKey,
|
||||
'selected': ko.observable(!!publicKey),
|
||||
'removable': ko.observable(
|
||||
!this.sign() || !this.signKey() || this.signKey().key.id !== publicKey.id
|
||||
),
|
||||
'users': publicKey ? publicKey.users || [recEmail] : [recEmail],
|
||||
'hash': publicKey ? publicKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() : '',
|
||||
'key': publicKey
|
||||
}))
|
||||
: [];
|
||||
}),
|
||||
true
|
||||
)
|
||||
),
|
||||
(encryptKey) => encryptKey.hash
|
||||
rec.map(recEmail => {
|
||||
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||
return keys
|
||||
? keys.map(publicKey => ({
|
||||
'empty': !publicKey,
|
||||
'selected': ko.observable(!!publicKey),
|
||||
'removable': ko.observable(
|
||||
!this.sign() || !this.signKey() || this.signKey().key.id !== publicKey.id
|
||||
),
|
||||
'users': publicKey ? publicKey.users || [recEmail] : [recEmail],
|
||||
'hash': publicKey ? publicKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() : '',
|
||||
'key': publicKey
|
||||
}))
|
||||
: [];
|
||||
}).flat().filter(
|
||||
(encryptKey, index, self) => encryptKey => !!encryptKey.hash && self.indexOf(encryptKey) == index
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import key from 'key';
|
||||
|
|
@ -171,7 +170,9 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
const checked = this.contactsChecked(),
|
||||
selected = this.currentContact();
|
||||
|
||||
return _.union(checked, selected ? [selected] : []);
|
||||
return selected
|
||||
? checked.concat([selected]).filter((value, index, self) => self.indexOf(value) == index)
|
||||
: checked;
|
||||
});
|
||||
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(() =>
|
||||
|
|
@ -253,7 +254,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
aE = aE.filter(value => !!value);
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(aE)) {
|
||||
|
|
@ -596,7 +597,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
return contact.parse(item) ? contact : null;
|
||||
});
|
||||
|
||||
list = _.compact(list);
|
||||
list = list.filter(value => !!value);
|
||||
|
||||
count = pInt(data.Result.Count);
|
||||
count = 0 < count ? count : 0;
|
||||
|
|
|
|||
|
|
@ -453,11 +453,11 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
// aTo = [],
|
||||
// EmailModel = require('Model/Email').default,
|
||||
// fParseEmailLine = function(sLine) {
|
||||
// return sLine ? _.compact([window.decodeURIComponent(sLine)].map(sItem => {
|
||||
// return sLine ? [window.decodeURIComponent(sLine)].map(sItem => {
|
||||
// var oEmailModel = new EmailModel();
|
||||
// oEmailModel.parse(sItem);
|
||||
// return '' !== oEmailModel.email ? oEmailModel : null;
|
||||
// })) : null;
|
||||
// }).filter(value => !!value) : null;
|
||||
// }
|
||||
// ;
|
||||
//
|
||||
|
|
@ -477,26 +477,24 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
listIndex = 0;
|
||||
|
||||
const div = $('<div>'),
|
||||
dynamicEls = _.compact(
|
||||
this.message().attachments().map(item => {
|
||||
if (item && !item.isLinked && item.isImage()) {
|
||||
if (item === attachment) {
|
||||
index = listIndex;
|
||||
}
|
||||
|
||||
listIndex += 1;
|
||||
|
||||
return {
|
||||
src: item.linkPreview(),
|
||||
thumb: item.linkThumbnail(),
|
||||
subHtml: item.fileName,
|
||||
downloadUrl: item.linkPreview()
|
||||
};
|
||||
dynamicEls = this.message().attachments().map(item => {
|
||||
if (item && !item.isLinked && item.isImage()) {
|
||||
if (item === attachment) {
|
||||
index = listIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
);
|
||||
listIndex += 1;
|
||||
|
||||
return {
|
||||
src: item.linkPreview(),
|
||||
thumb: item.linkThumbnail(),
|
||||
subHtml: item.fileName,
|
||||
downloadUrl: item.linkPreview()
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}).filter(value => !!value);
|
||||
|
||||
if (0 < dynamicEls.length) {
|
||||
div.on('onBeforeOpen.lg', () => {
|
||||
|
|
@ -885,7 +883,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
getAttachmentsHashes() {
|
||||
const atts = this.message() ? this.message().attachments() : [];
|
||||
return _.compact(atts.map(item => (item && !item.isLinked && item.checked() ? item.download : '')));
|
||||
return atts.map(item => (item && !item.isLinked && item.checked() ? item.download : '')).filter(value => !!value);
|
||||
}
|
||||
|
||||
downloadAsZip() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue