mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-07 12:15:51 +08: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
|
@ -40,7 +40,7 @@ class AdminApp extends AbstractApp {
|
||||||
DomainStore.domains.loading(false);
|
DomainStore.domains.loading(false);
|
||||||
if (StorageResultType.Success === result && data && data.Result) {
|
if (StorageResultType.Success === result && data && data.Result) {
|
||||||
DomainStore.domains(
|
DomainStore.domains(
|
||||||
_.map(data.Result, ([enabled, alias], name) => ({
|
Object.entries(data.Result).map(([enabled, alias], name) => ({
|
||||||
name: name,
|
name: name,
|
||||||
disabled: ko.observable(!enabled),
|
disabled: ko.observable(!enabled),
|
||||||
alias: alias,
|
alias: alias,
|
||||||
|
@ -57,7 +57,7 @@ class AdminApp extends AbstractApp {
|
||||||
PluginStore.plugins.loading(false);
|
PluginStore.plugins.loading(false);
|
||||||
if (StorageResultType.Success === result && data && data.Result) {
|
if (StorageResultType.Success === result && data && data.Result) {
|
||||||
PluginStore.plugins(
|
PluginStore.plugins(
|
||||||
_.map(data.Result, (item) => ({
|
data.Result.map(item => ({
|
||||||
name: item.Name,
|
name: item.Name,
|
||||||
disabled: ko.observable(!item.Enabled),
|
disabled: ko.observable(!item.Enabled),
|
||||||
configured: ko.observable(!!item.Configured)
|
configured: ko.observable(!!item.Configured)
|
||||||
|
@ -87,7 +87,7 @@ class AdminApp extends AbstractApp {
|
||||||
|
|
||||||
if (isArray(data.Result.List)) {
|
if (isArray(data.Result.List)) {
|
||||||
list = _.compact(
|
list = _.compact(
|
||||||
_.map(data.Result.List, (item) => {
|
data.Result.List.map(item => {
|
||||||
if (item) {
|
if (item) {
|
||||||
item.loading = ko.observable(!isUnd(loading[item.file]));
|
item.loading = ko.observable(!isUnd(loading[item.file]));
|
||||||
return 'core' === item.type && !item.canBeInstalled ? null : item;
|
return 'core' === item.type && !item.canBeInstalled ? null : item;
|
||||||
|
|
|
@ -520,7 +520,7 @@ class AppUser extends AbstractApp {
|
||||||
.getKeyId()
|
.getKeyId()
|
||||||
.toHex()
|
.toHex()
|
||||||
.toLowerCase(),
|
.toLowerCase(),
|
||||||
_.uniq(_.compact(_.map(oItem.getKeyIds(), (item) => (item && item.toHex ? item.toHex() : null)))),
|
_.uniq(_.compact(oItem.getKeyIds().map(item => (item && item.toHex ? item.toHex() : null)))),
|
||||||
aUsers,
|
aUsers,
|
||||||
aEmails,
|
aEmails,
|
||||||
oItem.isPrivate(),
|
oItem.isPrivate(),
|
||||||
|
@ -590,9 +590,8 @@ class AppUser extends AbstractApp {
|
||||||
delegateRunOnDestroy(AccountStore.accounts());
|
delegateRunOnDestroy(AccountStore.accounts());
|
||||||
|
|
||||||
AccountStore.accounts(
|
AccountStore.accounts(
|
||||||
_.map(
|
oData.Result.Accounts.map(
|
||||||
oData.Result.Accounts,
|
sValue => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0)
|
||||||
(sValue) => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +605,7 @@ class AppUser extends AbstractApp {
|
||||||
delegateRunOnDestroy(IdentityStore.identities());
|
delegateRunOnDestroy(IdentityStore.identities());
|
||||||
|
|
||||||
IdentityStore.identities(
|
IdentityStore.identities(
|
||||||
_.map(oData.Result.Identities, (identityData) => {
|
oData.Result.Identities.map(identityData => {
|
||||||
const id = pString(identityData.Id),
|
const id = pString(identityData.Id),
|
||||||
email = pString(identityData.Email),
|
email = pString(identityData.Email),
|
||||||
identity = new IdentityModel(id, email);
|
identity = new IdentityModel(id, email);
|
||||||
|
@ -636,7 +635,7 @@ class AppUser extends AbstractApp {
|
||||||
|
|
||||||
TemplateStore.templates(
|
TemplateStore.templates(
|
||||||
_.compact(
|
_.compact(
|
||||||
_.map(data.Result.Templates, (templateData) => {
|
data.Result.Templates.map(templateData => {
|
||||||
const template = new TemplateModel();
|
const template = new TemplateModel();
|
||||||
return template.parse(templateData) ? template : null;
|
return template.parse(templateData) ? template : null;
|
||||||
})
|
})
|
||||||
|
@ -820,7 +819,7 @@ class AppUser extends AbstractApp {
|
||||||
messages = MessageStore.messageListChecked();
|
messages = MessageStore.messageListChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
rootUids = _.uniq(_.compact(_.map(messages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));
|
rootUids = _.uniq(_.compact(messages.map(oMessage => (oMessage && oMessage.uid ? oMessage.uid : null))));
|
||||||
|
|
||||||
if ('' !== sFolderFullNameRaw && 0 < rootUids.length) {
|
if ('' !== sFolderFullNameRaw && 0 < rootUids.length) {
|
||||||
switch (iSetAction) {
|
switch (iSetAction) {
|
||||||
|
@ -881,7 +880,7 @@ class AppUser extends AbstractApp {
|
||||||
Remote.suggestions((result, data) => {
|
Remote.suggestions((result, data) => {
|
||||||
if (StorageResultType.Success === result && data && isArray(data.Result)) {
|
if (StorageResultType.Success === result && data && isArray(data.Result)) {
|
||||||
autocompleteCallback(
|
autocompleteCallback(
|
||||||
_.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null)))
|
_.compact(data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null)))
|
||||||
);
|
);
|
||||||
} else if (StorageResultType.Abort !== result) {
|
} else if (StorageResultType.Abort !== result) {
|
||||||
autocompleteCallback([]);
|
autocompleteCallback([]);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import _ from '_';
|
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { isUnd } from 'Common/Utils';
|
import { isUnd } from 'Common/Utils';
|
||||||
import { AbstractComponent } from 'Component/Abstract';
|
import { AbstractComponent } from 'Component/Abstract';
|
||||||
|
@ -21,7 +20,7 @@ class AbstractRadio extends AbstractComponent {
|
||||||
this.readOnly = isUnd(params.readOnly) ? false : !!params.readOnly;
|
this.readOnly = isUnd(params.readOnly) ? false : !!params.readOnly;
|
||||||
|
|
||||||
if (params.values) {
|
if (params.values) {
|
||||||
this.values(_.map(params.values, (label, value) => ({ label: label, value: value })));
|
this.values(Object.entries(params.values).map((label, value) => ({ label: label, value: value })));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.click = this.click.bind(this);
|
this.click = this.click.bind(this);
|
||||||
|
|
15
dev/External/ko.js
vendored
15
dev/External/ko.js
vendored
|
@ -824,14 +824,13 @@ ko.bindingHandlers.emailsTags = {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
parseHook: (input) =>
|
parseHook: (input) =>
|
||||||
_.map(
|
_.flatten(
|
||||||
_.flatten(
|
input.map(inputValue => {
|
||||||
_.map(input, (inputValue) => {
|
const values = EmailModel.parseEmailLine(inputValue);
|
||||||
const values = EmailModel.parseEmailLine(inputValue);
|
return values.length ? values : inputValue;
|
||||||
return values.length ? values : inputValue;
|
})
|
||||||
})
|
).map(
|
||||||
),
|
item => (_.isObject(item) ? [item.toLine(false), item] : [item, null])
|
||||||
(item) => (_.isObject(item) ? [item.toLine(false), item] : [item, null])
|
|
||||||
),
|
),
|
||||||
change: (event) => {
|
change: (event) => {
|
||||||
$el.data('EmailsTagsValue', event.target.value);
|
$el.data('EmailsTagsValue', event.target.value);
|
||||||
|
|
|
@ -187,7 +187,7 @@ export const staticCombinedIconClass = (data) => {
|
||||||
|
|
||||||
if (isNonEmptyArray(data)) {
|
if (isNonEmptyArray(data)) {
|
||||||
result = 'icon-attachment';
|
result = 'icon-attachment';
|
||||||
types = _.uniq(_.compact(_.map(data, (item) => (item ? staticFileType(getFileExtension(item[0]), item[1]) : ''))));
|
types = _.uniq(_.compact(data.map(item => (item ? staticFileType(getFileExtension(item[0]), item[1]) : ''))));
|
||||||
|
|
||||||
if (types && 1 === types.length && types[0]) {
|
if (types && 1 === types.length && types[0]) {
|
||||||
switch (types[0]) {
|
switch (types[0]) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ class EmailModel {
|
||||||
const parsedResult = addressparser(line);
|
const parsedResult = addressparser(line);
|
||||||
if (isNonEmptyArray(parsedResult)) {
|
if (isNonEmptyArray(parsedResult)) {
|
||||||
return _.compact(
|
return _.compact(
|
||||||
_.map(parsedResult, (item) =>
|
parsedResult.map(item =>
|
||||||
item.address ? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '') : null
|
item.address ? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '') : null
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -190,7 +190,7 @@ class FilterModel extends AbstractModel {
|
||||||
Enabled: this.enabled() ? '1' : '0',
|
Enabled: this.enabled() ? '1' : '0',
|
||||||
Name: this.name(),
|
Name: this.name(),
|
||||||
ConditionsType: this.conditionsType(),
|
ConditionsType: this.conditionsType(),
|
||||||
Conditions: _.map(this.conditions(), (item) => item.toJson()),
|
Conditions: this.conditions().map(item => item.toJson()),
|
||||||
|
|
||||||
ActionValue: this.actionValue(),
|
ActionValue: this.actionValue(),
|
||||||
ActionValueSecond: this.actionValueSecond(),
|
ActionValueSecond: this.actionValueSecond(),
|
||||||
|
@ -231,7 +231,7 @@ class FilterModel extends AbstractModel {
|
||||||
if (isNonEmptyArray(json.Conditions)) {
|
if (isNonEmptyArray(json.Conditions)) {
|
||||||
this.conditions(
|
this.conditions(
|
||||||
_.compact(
|
_.compact(
|
||||||
_.map(json.Conditions, (aData) => {
|
json.Conditions.map(aData => {
|
||||||
const filterCondition = new FilterConditionModel();
|
const filterCondition = new FilterConditionModel();
|
||||||
return filterCondition && filterCondition.parse(aData) ? filterCondition : null;
|
return filterCondition && filterCondition.parse(aData) ? filterCondition : null;
|
||||||
})
|
})
|
||||||
|
@ -282,7 +282,7 @@ class FilterModel extends AbstractModel {
|
||||||
filter.actionKeep(this.actionKeep());
|
filter.actionKeep(this.actionKeep());
|
||||||
filter.actionNoStop(this.actionNoStop());
|
filter.actionNoStop(this.actionNoStop());
|
||||||
|
|
||||||
filter.conditions(_.map(this.conditions(), (item) => item.cloneSelf()));
|
filter.conditions(this.conditions().map(item => item.cloneSelf()));
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,8 +202,7 @@ class MessageModel extends AbstractModel {
|
||||||
getEmails(properties) {
|
getEmails(properties) {
|
||||||
return _.compact(
|
return _.compact(
|
||||||
_.uniq(
|
_.uniq(
|
||||||
_.map(
|
_.reduce(properties, (carry, property) => carry.concat(this[property]), []).map(
|
||||||
_.reduce(properties, (carry, property) => carry.concat(this[property]), []),
|
|
||||||
(oItem) => (oItem ? oItem.email : '')
|
(oItem) => (oItem ? oItem.email : '')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -628,7 +627,7 @@ class MessageModel extends AbstractModel {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
attachmentsToStringLine() {
|
attachmentsToStringLine() {
|
||||||
const attachLines = _.map(this.attachments(), (item) => item.fileName + ' (' + item.friendlySize + ')');
|
const attachLines = this.attachments().map(item => item.fileName + ' (' + item.friendlySize + ')');
|
||||||
return attachLines && 0 < attachLines.length ? attachLines.join(', ') : '';
|
return attachLines && 0 < attachLines.length ? attachLines.join(', ') : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import _ from '_';
|
|
||||||
|
|
||||||
import { pString, pInt, isArray, trim, boolToAjax } from 'Common/Utils';
|
import { pString, pInt, isArray, trim, boolToAjax } from 'Common/Utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -247,7 +245,7 @@ class RemoteUserAjax extends AbstractAjaxRemote {
|
||||||
this.defaultRequest(fCallback, 'FiltersSave', {
|
this.defaultRequest(fCallback, 'FiltersSave', {
|
||||||
'Raw': raw,
|
'Raw': raw,
|
||||||
'RawIsActive': boolToAjax(isRawIsActive),
|
'RawIsActive': boolToAjax(isRawIsActive),
|
||||||
'Filters': _.map(filters, (item) => item.toJson())
|
'Filters': filters.map(item => item.toJson())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ContactsAdminSettings {
|
||||||
|
|
||||||
this.contactsTypes = ko.observableArray([]);
|
this.contactsTypes = ko.observableArray([]);
|
||||||
this.contactsTypesOptions = ko.computed(() =>
|
this.contactsTypesOptions = ko.computed(() =>
|
||||||
_.map(this.contactsTypes(), (value) => {
|
this.contactsTypes().map(value => {
|
||||||
const disabled = supportedTypes.includes(value);
|
const disabled = supportedTypes.includes(value);
|
||||||
return {
|
return {
|
||||||
'id': value,
|
'id': value,
|
||||||
|
|
|
@ -63,7 +63,7 @@ class GeneralAdminSettings {
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
this.themesOptions = ko.computed(() =>
|
this.themesOptions = ko.computed(() =>
|
||||||
_.map(this.themes(), (theme) => ({ optValue: theme, optText: convertThemeName(theme) }))
|
this.themes().map(theme => ({ optValue: theme, optText: convertThemeName(theme) }))
|
||||||
);
|
);
|
||||||
|
|
||||||
this.languageFullName = ko.computed(() => convertLangName(this.language()));
|
this.languageFullName = ko.computed(() => convertLangName(this.language()));
|
||||||
|
|
|
@ -114,7 +114,7 @@ class FiltersUserSettings {
|
||||||
|
|
||||||
this.filters(
|
this.filters(
|
||||||
_.compact(
|
_.compact(
|
||||||
_.map(data.Result.Filters, (aItem) => {
|
data.Result.Filters.map(aItem => {
|
||||||
const filter = new FilterModel();
|
const filter = new FilterModel();
|
||||||
return filter && filter.parse(aItem) ? filter : null;
|
return filter && filter.parse(aItem) ? filter : null;
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import window from 'window';
|
import window from 'window';
|
||||||
import _ from '_';
|
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import Jua from 'Jua';
|
import Jua from 'Jua';
|
||||||
|
@ -63,7 +62,7 @@ class ThemesUserSettings {
|
||||||
const currentTheme = this.theme();
|
const currentTheme = this.theme();
|
||||||
|
|
||||||
this.themesObjects(
|
this.themesObjects(
|
||||||
_.map(this.themes(), (theme) => ({
|
this.themes().map(theme => ({
|
||||||
name: theme,
|
name: theme,
|
||||||
nameDisplay: convertThemeName(theme),
|
nameDisplay: convertThemeName(theme),
|
||||||
selected: ko.observable(theme === currentTheme),
|
selected: ko.observable(theme === currentTheme),
|
||||||
|
|
|
@ -17,7 +17,7 @@ class AccountUserStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
computers() {
|
computers() {
|
||||||
this.accountsEmails = ko.computed(() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
|
this.accountsEmails = ko.computed(() => _.compact(this.accounts().map(item => (item ? item.email : null))));
|
||||||
|
|
||||||
this.accountsUnreadCount = ko.computed(() => 0);
|
this.accountsUnreadCount = ko.computed(() => 0);
|
||||||
// this.accountsUnreadCount = ko.computed(() => {
|
// this.accountsUnreadCount = ko.computed(() => {
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FolderUserStore {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.folderListSystem = ko.computed(() =>
|
this.folderListSystem = ko.computed(() =>
|
||||||
_.compact(_.map(this.folderListSystemNames(), (name) => getFolderFromCacheList(name)))
|
_.compact(this.folderListSystemNames().map(name => getFolderFromCacheList(name)))
|
||||||
);
|
);
|
||||||
|
|
||||||
this.folderMenuForMove = ko.computed(() =>
|
this.folderMenuForMove = ko.computed(() =>
|
||||||
|
|
|
@ -6,7 +6,7 @@ class IdentityUserStore {
|
||||||
this.identities = ko.observableArray([]);
|
this.identities = ko.observableArray([]);
|
||||||
this.identities.loading = ko.observable(false).extend({ throttle: 100 });
|
this.identities.loading = ko.observable(false).extend({ throttle: 100 });
|
||||||
|
|
||||||
this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
|
this.identitiesIDS = ko.computed(() => _.compact(this.identities().map(item => (item ? item.id : null))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ class MessageUserStore {
|
||||||
* @param {boolean=} copy = false
|
* @param {boolean=} copy = false
|
||||||
*/
|
*/
|
||||||
removeMessagesFromList(fromFolderFullNameRaw, uidForRemove, toFolderFullNameRaw = '', copy = false) {
|
removeMessagesFromList(fromFolderFullNameRaw, uidForRemove, toFolderFullNameRaw = '', copy = false) {
|
||||||
uidForRemove = _.map(uidForRemove, (mValue) => pInt(mValue));
|
uidForRemove = uidForRemove.map(mValue => pInt(mValue));
|
||||||
|
|
||||||
let unseenCount = 0,
|
let unseenCount = 0,
|
||||||
messageList = this.messageList(),
|
messageList = this.messageList(),
|
||||||
|
@ -709,7 +709,7 @@ class MessageUserStore {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
calculateMessageListHash(list) {
|
calculateMessageListHash(list) {
|
||||||
return _.map(list, (message) => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join(
|
return list.map(message => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join(
|
||||||
'|'
|
'|'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PgpUserStore {
|
||||||
findPublicKeysByEmail(email) {
|
findPublicKeysByEmail(email) {
|
||||||
return _.compact(
|
return _.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
_.map(this.openpgpkeysPublic(), (item) => {
|
this.openpgpkeysPublic().map(item => {
|
||||||
const key = item && item.emails.includes(email) ? item : null;
|
const key = item && item.emails.includes(email) ? item : null;
|
||||||
return key ? key.getNativeKeys() : [null];
|
return key ? key.getNativeKeys() : [null];
|
||||||
}),
|
}),
|
||||||
|
@ -56,7 +56,7 @@ class PgpUserStore {
|
||||||
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
||||||
return _.compact(
|
return _.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
_.map(signingKeyIds, (id) => {
|
signingKeyIds.map(id => {
|
||||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||||
return key ? key.getNativeKeys() : [null];
|
return key ? key.getNativeKeys() : [null];
|
||||||
}),
|
}),
|
||||||
|
@ -69,7 +69,7 @@ class PgpUserStore {
|
||||||
let result = isArray(encryptionKeyIds)
|
let result = isArray(encryptionKeyIds)
|
||||||
? _.compact(
|
? _.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
_.map(encryptionKeyIds, (id) => {
|
encryptionKeyIds.map(id => {
|
||||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||||
}),
|
}),
|
||||||
|
@ -82,13 +82,13 @@ class PgpUserStore {
|
||||||
result = _.uniq(
|
result = _.uniq(
|
||||||
_.compact(
|
_.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
_.map(recipients, (sEmail) => {
|
recipients.map(sEmail => {
|
||||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||||
return keys
|
return keys
|
||||||
? returnWrapKeys
|
? returnWrapKeys
|
||||||
? keys
|
? keys
|
||||||
: _.flatten(
|
: _.flatten(
|
||||||
_.map(keys, (key) => key.getNativeKeys()),
|
keys.map(key => key.getNativeKeys()),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
: [null];
|
: [null];
|
||||||
|
@ -297,7 +297,7 @@ class PgpUserStore {
|
||||||
} else if (validPrivateKey) {
|
} else if (validPrivateKey) {
|
||||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||||
additional = keyIds
|
additional = keyIds
|
||||||
? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ')
|
? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
store.controlsHelper(
|
store.controlsHelper(
|
||||||
|
@ -354,7 +354,7 @@ class PgpUserStore {
|
||||||
} else {
|
} else {
|
||||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||||
additional = keyIds
|
additional = keyIds
|
||||||
? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ')
|
? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
store.controlsHelper(
|
store.controlsHelper(
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TemplateUserStore {
|
||||||
|
|
||||||
subscribers() {
|
subscribers() {
|
||||||
this.templates.subscribe((list) => {
|
this.templates.subscribe((list) => {
|
||||||
this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null))));
|
this.templatesNames(_.compact(list.map(item => (item ? item.name : null))));
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.templatesNames.subscribe((aList) => {
|
// this.templatesNames.subscribe((aList) => {
|
||||||
|
|
|
@ -257,7 +257,7 @@ class ComposePopupView extends AbstractViewNext {
|
||||||
|
|
||||||
this.identities = IdentityStore.identities;
|
this.identities = IdentityStore.identities;
|
||||||
this.identitiesOptions = ko.computed(() =>
|
this.identitiesOptions = ko.computed(() =>
|
||||||
_.map(IdentityStore.identities(), (item) => ({
|
IdentityStore.identities().map(item => ({
|
||||||
'item': item,
|
'item': item,
|
||||||
'optValue': item.id(),
|
'optValue': item.id(),
|
||||||
'optText': item.formattedName()
|
'optText': item.formattedName()
|
||||||
|
@ -541,7 +541,7 @@ class ComposePopupView extends AbstractViewNext {
|
||||||
|
|
||||||
emailsSource(oData, fResponse) {
|
emailsSource(oData, fResponse) {
|
||||||
getApp().getAutocomplete(oData.term, (aData) => {
|
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) {
|
addEmailsTo(fKoValue, emails) {
|
||||||
if (isNonEmptyArray(emails)) {
|
if (isNonEmptyArray(emails)) {
|
||||||
const value = trim(fKoValue()),
|
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(', ')));
|
fKoValue(value + ('' === value ? '' : ', ') + trim(values.join(', ')));
|
||||||
}
|
}
|
||||||
|
@ -873,7 +873,7 @@ class ComposePopupView extends AbstractViewNext {
|
||||||
*/
|
*/
|
||||||
emailArrayToStringLineHelper(aList, bFriendly) {
|
emailArrayToStringLineHelper(aList, bFriendly) {
|
||||||
bFriendly = !!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}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
getAttachmentsDownloadsForUpload() {
|
getAttachmentsDownloadsForUpload() {
|
||||||
return _.map(
|
return this.attachments().filter(item => item && '' === item.tempName()).map(
|
||||||
this.attachments().filter(item => item && '' === item.tempName()),
|
item => item.id
|
||||||
(item) => item.id
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,14 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
||||||
this.signKey = ko.observable(null);
|
this.signKey = ko.observable(null);
|
||||||
this.encryptKeys = ko.observableArray([]);
|
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(() => {
|
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) {
|
if (this.signKey() && this.signKey().key.id === oKey.id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _.map(oKey.users, (user) => ({
|
return oKey.users.map(user => ({
|
||||||
'id': oKey.guid,
|
'id': oKey.guid,
|
||||||
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
||||||
'key': oKey,
|
'key': oKey,
|
||||||
|
@ -63,11 +63,11 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.publicKeysOptions = ko.computed(() => {
|
this.publicKeysOptions = ko.computed(() => {
|
||||||
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
const opts = PgpStore.openpgpkeysPublic().map((oKey, index) => {
|
||||||
if (this.encryptKeysView().includes(oKey)) {
|
if (this.encryptKeysView().includes(oKey)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _.map(oKey.users, (user) => ({
|
return oKey.users.map(user => ({
|
||||||
'id': oKey.guid,
|
'id': oKey.guid,
|
||||||
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user,
|
||||||
'key': oKey,
|
'key': oKey,
|
||||||
|
@ -356,7 +356,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
||||||
|
|
||||||
rec = rec.join(', ').split(',');
|
rec = rec.join(', ').split(',');
|
||||||
rec = _.compact(
|
rec = _.compact(
|
||||||
_.map(rec, (value) => {
|
rec.map(value => {
|
||||||
email.clear();
|
email.clear();
|
||||||
email.parse(trim(value));
|
email.parse(trim(value));
|
||||||
return '' === email.email ? false : email.email;
|
return '' === email.email ? false : email.email;
|
||||||
|
@ -386,10 +386,10 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
|
||||||
_.uniq(
|
_.uniq(
|
||||||
_.compact(
|
_.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
_.map(rec, (recEmail) => {
|
rec.map(recEmail => {
|
||||||
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||||
return keys
|
return keys
|
||||||
? _.map(keys, (publicKey) => ({
|
? keys.map(publicKey => ({
|
||||||
'empty': !publicKey,
|
'empty': !publicKey,
|
||||||
'selected': ko.observable(!!publicKey),
|
'selected': ko.observable(!!publicKey),
|
||||||
'removable': ko.observable(
|
'removable': ko.observable(
|
||||||
|
|
|
@ -175,7 +175,7 @@ class ContactsPopupView extends AbstractViewNext {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.contactsCheckedOrSelectedUids = ko.computed(() =>
|
this.contactsCheckedOrSelectedUids = ko.computed(() =>
|
||||||
_.map(this.contactsCheckedOrSelected(), (contact) => contact.idContact)
|
this.contactsCheckedOrSelected().map(contact => contact.idContact)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.selector = new Selector(
|
this.selector = new Selector(
|
||||||
|
@ -202,7 +202,7 @@ class ContactsPopupView extends AbstractViewNext {
|
||||||
this.watchDirty = ko.observable(false);
|
this.watchDirty = ko.observable(false);
|
||||||
this.watchHash = 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);
|
// this.saveCommandDebounce = _.debounce(this.saveCommand.bind(this), 1000);
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ class ContactsPopupView extends AbstractViewNext {
|
||||||
|
|
||||||
const aC = this.contactsCheckedOrSelected();
|
const aC = this.contactsCheckedOrSelected();
|
||||||
if (isNonEmptyArray(aC)) {
|
if (isNonEmptyArray(aC)) {
|
||||||
aE = _.map(aC, (oItem) => {
|
aE = aC.map(oItem => {
|
||||||
if (oItem) {
|
if (oItem) {
|
||||||
const data = oItem.getNameAndEmailHelper(),
|
const data = oItem.getNameAndEmailHelper(),
|
||||||
email = data ? new EmailModel(data[0], data[1]) : null;
|
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 (StorageResultType.Success === result && data && data.Result && data.Result.List) {
|
||||||
if (isNonEmptyArray(data.Result.List)) {
|
if (isNonEmptyArray(data.Result.List)) {
|
||||||
list = _.map(data.Result.List, (item) => {
|
list = data.Result.List.map(item => {
|
||||||
const contact = new ContactModel();
|
const contact = new ContactModel();
|
||||||
return contact.parse(item) ? contact : null;
|
return contact.parse(item) ? contact : null;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import _ from '_';
|
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { StorageResultType, Notification } from 'Common/Enums';
|
import { StorageResultType, Notification } from 'Common/Enums';
|
||||||
|
@ -33,7 +32,7 @@ class DomainAliasPopupView extends AbstractViewNext {
|
||||||
this.domains = DomainStore.domainsWithoutAliases;
|
this.domains = DomainStore.domainsWithoutAliases;
|
||||||
|
|
||||||
this.domainsOptions = ko.computed(() =>
|
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());
|
this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias());
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import _ from '_';
|
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { convertLangName } from 'Common/Utils';
|
import { convertLangName } from 'Common/Utils';
|
||||||
|
@ -22,7 +21,7 @@ class LanguagesPopupView extends AbstractViewNext {
|
||||||
|
|
||||||
this.languages = ko.computed(() => {
|
this.languages = ko.computed(() => {
|
||||||
const userLanguage = this.userLanguage();
|
const userLanguage = this.userLanguage();
|
||||||
return _.map(this.langs(), (language) => ({
|
return this.langs().map(language => ({
|
||||||
key: language,
|
key: language,
|
||||||
user: language === userLanguage,
|
user: language === userLanguage,
|
||||||
selected: ko.observable(false),
|
selected: ko.observable(false),
|
||||||
|
|
|
@ -88,7 +88,7 @@ class PluginPopupView extends AbstractViewNext {
|
||||||
const config = oPlugin.Config;
|
const config = oPlugin.Config;
|
||||||
if (isNonEmptyArray(config)) {
|
if (isNonEmptyArray(config)) {
|
||||||
this.configures(
|
this.configures(
|
||||||
_.map(config, (item) => ({
|
config.map(item => ({
|
||||||
'value': ko.observable(item[0]),
|
'value': ko.observable(item[0]),
|
||||||
'placeholder': ko.observable(item[6]),
|
'placeholder': ko.observable(item[6]),
|
||||||
'Name': item[1],
|
'Name': item[1],
|
||||||
|
|
|
@ -651,7 +651,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
||||||
flagMessages(currentMessage) {
|
flagMessages(currentMessage) {
|
||||||
const checked = this.messageListCheckedOrSelected();
|
const checked = this.messageListCheckedOrSelected();
|
||||||
if (currentMessage) {
|
if (currentMessage) {
|
||||||
const checkedUids = _.map(checked, (message) => message.uid);
|
const checkedUids = checked.map(message => message.uid);
|
||||||
if (0 < checkedUids.length && checkedUids.includes(currentMessage.uid)) {
|
if (0 < checkedUids.length && checkedUids.includes(currentMessage.uid)) {
|
||||||
this.setAction(
|
this.setAction(
|
||||||
currentMessage.folderFullNameRaw,
|
currentMessage.folderFullNameRaw,
|
||||||
|
|
|
@ -453,7 +453,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
// aTo = [],
|
// aTo = [],
|
||||||
// EmailModel = require('Model/Email').default,
|
// EmailModel = require('Model/Email').default,
|
||||||
// fParseEmailLine = function(sLine) {
|
// fParseEmailLine = function(sLine) {
|
||||||
// return sLine ? _.compact(_.map([window.decodeURIComponent(sLine)], function(sItem) {
|
// return sLine ? _.compact([window.decodeURIComponent(sLine)].map(sItem => {
|
||||||
// var oEmailModel = new EmailModel();
|
// var oEmailModel = new EmailModel();
|
||||||
// oEmailModel.parse(sItem);
|
// oEmailModel.parse(sItem);
|
||||||
// return '' !== oEmailModel.email ? oEmailModel : null;
|
// return '' !== oEmailModel.email ? oEmailModel : null;
|
||||||
|
@ -478,7 +478,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
|
|
||||||
const div = $('<div>'),
|
const div = $('<div>'),
|
||||||
dynamicEls = _.compact(
|
dynamicEls = _.compact(
|
||||||
_.map(this.message().attachments(), (item) => {
|
this.message().attachments().map(item => {
|
||||||
if (item && !item.isLinked && item.isImage()) {
|
if (item && !item.isLinked && item.isImage()) {
|
||||||
if (item === attachment) {
|
if (item === attachment) {
|
||||||
index = listIndex;
|
index = listIndex;
|
||||||
|
@ -885,7 +885,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
||||||
|
|
||||||
getAttachmentsHashes() {
|
getAttachmentsHashes() {
|
||||||
const atts = this.message() ? this.message().attachments() : [];
|
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() {
|
downloadAsZip() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue