mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Underscore.js _.map() to native Array.map() (optional with Object.entries/values)
This commit is contained in:
parent
032fa8c736
commit
a82575a830
27 changed files with 68 additions and 78 deletions
|
|
@ -257,7 +257,7 @@ class ComposePopupView extends AbstractViewNext {
|
|||
|
||||
this.identities = IdentityStore.identities;
|
||||
this.identitiesOptions = ko.computed(() =>
|
||||
_.map(IdentityStore.identities(), (item) => ({
|
||||
IdentityStore.identities().map(item => ({
|
||||
'item': item,
|
||||
'optValue': item.id(),
|
||||
'optText': item.formattedName()
|
||||
|
|
@ -541,7 +541,7 @@ class ComposePopupView extends AbstractViewNext {
|
|||
|
||||
emailsSource(oData, fResponse) {
|
||||
getApp().getAutocomplete(oData.term, (aData) => {
|
||||
fResponse(_.map(aData, (oEmailItem) => oEmailItem.toLine(false)));
|
||||
fResponse(aData.map(oEmailItem => oEmailItem.toLine(false)));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -859,7 +859,7 @@ class ComposePopupView extends AbstractViewNext {
|
|||
addEmailsTo(fKoValue, emails) {
|
||||
if (isNonEmptyArray(emails)) {
|
||||
const value = trim(fKoValue()),
|
||||
values = _.uniq(_.compact(_.map(emails, (item) => (item ? item.toLine(false) : null))));
|
||||
values = _.uniq(_.compact(emails.map(item => (item ? item.toLine(false) : null))));
|
||||
|
||||
fKoValue(value + ('' === value ? '' : ', ') + trim(values.join(', ')));
|
||||
}
|
||||
|
|
@ -873,7 +873,7 @@ class ComposePopupView extends AbstractViewNext {
|
|||
*/
|
||||
emailArrayToStringLineHelper(aList, bFriendly) {
|
||||
bFriendly = !!bFriendly;
|
||||
return _.map(aList, (item) => item.toLine(bFriendly)).join(', ');
|
||||
return aList.map(item => item.toLine(bFriendly)).join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1605,9 +1605,8 @@ class ComposePopupView extends AbstractViewNext {
|
|||
* @returns {Array}
|
||||
*/
|
||||
getAttachmentsDownloadsForUpload() {
|
||||
return _.map(
|
||||
this.attachments().filter(item => item && '' === item.tempName()),
|
||||
(item) => item.id
|
||||
return this.attachments().filter(item => item && '' === item.tempName()).map(
|
||||
item => item.id
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
|
||||
this.encryptKeysView = ko.computed(() => _.compact(_.map(this.encryptKeys(), (oKey) => (oKey ? oKey.key : null))));
|
||||
this.encryptKeysView = ko.computed(() => _.compact(this.encryptKeys().map(oKey => (oKey ? oKey.key : null))));
|
||||
|
||||
this.privateKeysOptions = ko.computed(() => {
|
||||
const opts = _.map(PgpStore.openpgpkeysPrivate(), (oKey, iIndex) => {
|
||||
const opts = PgpStore.openpgpkeysPrivate().map((oKey, iIndex) => {
|
||||
if (this.signKey() && this.signKey().key.id === oKey.id) {
|
||||
return null;
|
||||
}
|
||||
return _.map(oKey.users, (user) => ({
|
||||
return oKey.users.map(user => ({
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
||||
'key': oKey,
|
||||
|
|
@ -63,11 +63,11 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
});
|
||||
|
||||
this.publicKeysOptions = ko.computed(() => {
|
||||
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
||||
const opts = PgpStore.openpgpkeysPublic().map((oKey, index) => {
|
||||
if (this.encryptKeysView().includes(oKey)) {
|
||||
return null;
|
||||
}
|
||||
return _.map(oKey.users, (user) => ({
|
||||
return oKey.users.map(user => ({
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
||||
'key': oKey,
|
||||
|
|
@ -356,7 +356,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
|
||||
rec = rec.join(', ').split(',');
|
||||
rec = _.compact(
|
||||
_.map(rec, (value) => {
|
||||
rec.map(value => {
|
||||
email.clear();
|
||||
email.parse(trim(value));
|
||||
return '' === email.email ? false : email.email;
|
||||
|
|
@ -386,10 +386,10 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
|||
_.uniq(
|
||||
_.compact(
|
||||
_.flatten(
|
||||
_.map(rec, (recEmail) => {
|
||||
rec.map(recEmail => {
|
||||
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||
return keys
|
||||
? _.map(keys, (publicKey) => ({
|
||||
? keys.map(publicKey => ({
|
||||
'empty': !publicKey,
|
||||
'selected': ko.observable(!!publicKey),
|
||||
'removable': ko.observable(
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
});
|
||||
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(() =>
|
||||
_.map(this.contactsCheckedOrSelected(), (contact) => contact.idContact)
|
||||
this.contactsCheckedOrSelected().map(contact => contact.idContact)
|
||||
);
|
||||
|
||||
this.selector = new Selector(
|
||||
|
|
@ -202,7 +202,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
this.watchDirty = ko.observable(false);
|
||||
this.watchHash = ko.observable(false);
|
||||
|
||||
this.viewHash = ko.computed(() => '' + _.map(this.viewProperties(), (oItem) => oItem.value()).join(''));
|
||||
this.viewHash = ko.computed(() => '' + this.viewProperties().map(oItem => oItem.value()).join(''));
|
||||
|
||||
// this.saveCommandDebounce = _.debounce(this.saveCommand.bind(this), 1000);
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
|
||||
const aC = this.contactsCheckedOrSelected();
|
||||
if (isNonEmptyArray(aC)) {
|
||||
aE = _.map(aC, (oItem) => {
|
||||
aE = aC.map(oItem => {
|
||||
if (oItem) {
|
||||
const data = oItem.getNameAndEmailHelper(),
|
||||
email = data ? new EmailModel(data[0], data[1]) : null;
|
||||
|
|
@ -591,7 +591,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.List) {
|
||||
if (isNonEmptyArray(data.Result.List)) {
|
||||
list = _.map(data.Result.List, (item) => {
|
||||
list = data.Result.List.map(item => {
|
||||
const contact = new ContactModel();
|
||||
return contact.parse(item) ? contact : null;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
|
|
@ -33,7 +32,7 @@ class DomainAliasPopupView extends AbstractViewNext {
|
|||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(() =>
|
||||
_.map(this.domains(), (item) => ({ optValue: item.name, optText: item.name }))
|
||||
this.domains().map(item => ({ optValue: item.name, optText: item.name }))
|
||||
);
|
||||
|
||||
this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import { convertLangName } from 'Common/Utils';
|
||||
|
|
@ -22,7 +21,7 @@ class LanguagesPopupView extends AbstractViewNext {
|
|||
|
||||
this.languages = ko.computed(() => {
|
||||
const userLanguage = this.userLanguage();
|
||||
return _.map(this.langs(), (language) => ({
|
||||
return this.langs().map(language => ({
|
||||
key: language,
|
||||
user: language === userLanguage,
|
||||
selected: ko.observable(false),
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class PluginPopupView extends AbstractViewNext {
|
|||
const config = oPlugin.Config;
|
||||
if (isNonEmptyArray(config)) {
|
||||
this.configures(
|
||||
_.map(config, (item) => ({
|
||||
config.map(item => ({
|
||||
'value': ko.observable(item[0]),
|
||||
'placeholder': ko.observable(item[6]),
|
||||
'Name': item[1],
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
|||
flagMessages(currentMessage) {
|
||||
const checked = this.messageListCheckedOrSelected();
|
||||
if (currentMessage) {
|
||||
const checkedUids = _.map(checked, (message) => message.uid);
|
||||
const checkedUids = checked.map(message => message.uid);
|
||||
if (0 < checkedUids.length && checkedUids.includes(currentMessage.uid)) {
|
||||
this.setAction(
|
||||
currentMessage.folderFullNameRaw,
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
// aTo = [],
|
||||
// EmailModel = require('Model/Email').default,
|
||||
// fParseEmailLine = function(sLine) {
|
||||
// return sLine ? _.compact(_.map([window.decodeURIComponent(sLine)], function(sItem) {
|
||||
// return sLine ? _.compact([window.decodeURIComponent(sLine)].map(sItem => {
|
||||
// var oEmailModel = new EmailModel();
|
||||
// oEmailModel.parse(sItem);
|
||||
// return '' !== oEmailModel.email ? oEmailModel : null;
|
||||
|
|
@ -478,7 +478,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
const div = $('<div>'),
|
||||
dynamicEls = _.compact(
|
||||
_.map(this.message().attachments(), (item) => {
|
||||
this.message().attachments().map(item => {
|
||||
if (item && !item.isLinked && item.isImage()) {
|
||||
if (item === attachment) {
|
||||
index = listIndex;
|
||||
|
|
@ -885,7 +885,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
getAttachmentsHashes() {
|
||||
const atts = this.message() ? this.message().attachments() : [];
|
||||
return _.compact(_.map(atts, (item) => (item && !item.isLinked && item.checked() ? item.download : '')));
|
||||
return _.compact(atts.map(item => (item && !item.isLinked && item.checked() ? item.download : '')));
|
||||
}
|
||||
|
||||
downloadAsZip() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue