mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +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
|
|
@ -1,5 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
|
|
@ -17,7 +16,9 @@ class AccountUserStore {
|
|||
}
|
||||
|
||||
computers() {
|
||||
this.accountsEmails = ko.computed(() => _.compact(this.accounts().map(item => (item ? item.email : null))));
|
||||
this.accountsEmails = ko.computed(
|
||||
() => this.accounts().map(item => (item ? item.email : null)).filter(value => !!value)
|
||||
);
|
||||
|
||||
this.accountsUnreadCount = ko.computed(() => 0);
|
||||
// this.accountsUnreadCount = ko.computed(() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ class FolderUserStore {
|
|||
});
|
||||
|
||||
this.folderListSystem = ko.computed(() =>
|
||||
_.compact(this.folderListSystemNames().map(name => getFolderFromCacheList(name)))
|
||||
this.folderListSystemNames().map(name => getFolderFromCacheList(name)).filter(value => !!value)
|
||||
);
|
||||
|
||||
this.folderMenuForMove = ko.computed(() =>
|
||||
|
|
@ -203,7 +202,7 @@ class FolderUserStore {
|
|||
return limit <= result.length;
|
||||
});
|
||||
|
||||
return _.uniq(result);
|
||||
return result.filter((value, index, self) => self.indexOf(value) == index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
class IdentityUserStore {
|
||||
|
|
@ -6,7 +5,9 @@ class IdentityUserStore {
|
|||
this.identities = ko.observableArray([]);
|
||||
this.identities.loading = ko.observable(false).extend({ throttle: 100 });
|
||||
|
||||
this.identitiesIDS = ko.computed(() => _.compact(this.identities().map(item => (item ? item.id : null))));
|
||||
this.identitiesIDS = ko.computed(
|
||||
() => this.identities().map(item => (item ? item.id : null)).filter(value => !!value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,9 @@ class MessageUserStore {
|
|||
focusedMessage = this.selectorMessageFocused();
|
||||
|
||||
if (checked.length) {
|
||||
return _.union(checked, selectedMessage ? [selectedMessage] : []);
|
||||
return selectedMessage
|
||||
? checked.concat([selectedMessage]).filter((value, index, self) => self.indexOf(value) == index)
|
||||
: checked;
|
||||
} else if (selectedMessage) {
|
||||
return [selectedMessage];
|
||||
}
|
||||
|
|
@ -167,7 +169,7 @@ class MessageUserStore {
|
|||
if (message) {
|
||||
result.push(message.uid);
|
||||
if (1 < message.threadsLen()) {
|
||||
result = _.union(result, message.threads());
|
||||
result = result.concat(message.threads()).filter((value, index, self) => self.indexOf(value) == index);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,62 +42,36 @@ class PgpUserStore {
|
|||
}
|
||||
|
||||
findPublicKeysByEmail(email) {
|
||||
return _.compact(
|
||||
_.flatten(
|
||||
this.openpgpkeysPublic().map(item => {
|
||||
const key = item && item.emails.includes(email) ? item : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
);
|
||||
return this.openpgpkeysPublic().map(item => {
|
||||
const key = item && item.emails.includes(email) ? item : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}).flat().filter(value => !!value);
|
||||
}
|
||||
|
||||
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
||||
return _.compact(
|
||||
_.flatten(
|
||||
signingKeyIds.map(id => {
|
||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
);
|
||||
return signingKeyIds.map(id => {
|
||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}).flat().filter(value => !!value);
|
||||
}
|
||||
|
||||
findPrivateKeysByEncryptionKeyIds(encryptionKeyIds, recipients, returnWrapKeys) {
|
||||
let result = isArray(encryptionKeyIds)
|
||||
? _.compact(
|
||||
_.flatten(
|
||||
encryptionKeyIds.map(id => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
)
|
||||
? encryptionKeyIds.map(id => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
}).flat().filter(value => !!value)
|
||||
: [];
|
||||
|
||||
if (0 === result.length && isNonEmptyArray(recipients)) {
|
||||
result = _.uniq(
|
||||
_.compact(
|
||||
_.flatten(
|
||||
recipients.map(sEmail => {
|
||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return keys
|
||||
? returnWrapKeys
|
||||
? keys
|
||||
: _.flatten(
|
||||
keys.map(key => key.getNativeKeys()),
|
||||
true
|
||||
)
|
||||
: [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
),
|
||||
(key) => key.id
|
||||
);
|
||||
result = recipients.map(sEmail => {
|
||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return keys
|
||||
? returnWrapKeys
|
||||
? keys
|
||||
: keys.map(key => key.getNativeKeys()).flat()
|
||||
: [null];
|
||||
}).flat().filter((key, index, self) => key => !!key.id && self.indexOf(key) == index);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -297,7 +271,7 @@ class PgpUserStore {
|
|||
} else if (validPrivateKey) {
|
||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(value => !!value).join(', ')
|
||||
: '';
|
||||
|
||||
store.controlsHelper(
|
||||
|
|
@ -354,7 +328,7 @@ class PgpUserStore {
|
|||
} else {
|
||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||
? keyIds.map(item => (item && item.toHex ? item.toHex() : null)).filter(value => !!value).join(', ')
|
||||
: '';
|
||||
|
||||
store.controlsHelper(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
// import Remote from 'Remote/User/Ajax';
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ class TemplateUserStore {
|
|||
|
||||
subscribers() {
|
||||
this.templates.subscribe((list) => {
|
||||
this.templatesNames(_.compact(list.map(item => (item ? item.name : null))));
|
||||
this.templatesNames(list.map(item => (item ? item.name : null)).filter(value => !!value));
|
||||
});
|
||||
|
||||
// this.templatesNames.subscribe((aList) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue