mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +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
|
|
@ -187,7 +187,7 @@ export const staticCombinedIconClass = (data) => {
|
|||
|
||||
if (isNonEmptyArray(data)) {
|
||||
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]) {
|
||||
switch (types[0]) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class EmailModel {
|
|||
const parsedResult = addressparser(line);
|
||||
if (isNonEmptyArray(parsedResult)) {
|
||||
return _.compact(
|
||||
_.map(parsedResult, (item) =>
|
||||
parsedResult.map(item =>
|
||||
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',
|
||||
Name: this.name(),
|
||||
ConditionsType: this.conditionsType(),
|
||||
Conditions: _.map(this.conditions(), (item) => item.toJson()),
|
||||
Conditions: this.conditions().map(item => item.toJson()),
|
||||
|
||||
ActionValue: this.actionValue(),
|
||||
ActionValueSecond: this.actionValueSecond(),
|
||||
|
|
@ -231,7 +231,7 @@ class FilterModel extends AbstractModel {
|
|||
if (isNonEmptyArray(json.Conditions)) {
|
||||
this.conditions(
|
||||
_.compact(
|
||||
_.map(json.Conditions, (aData) => {
|
||||
json.Conditions.map(aData => {
|
||||
const filterCondition = new FilterConditionModel();
|
||||
return filterCondition && filterCondition.parse(aData) ? filterCondition : null;
|
||||
})
|
||||
|
|
@ -282,7 +282,7 @@ class FilterModel extends AbstractModel {
|
|||
filter.actionKeep(this.actionKeep());
|
||||
filter.actionNoStop(this.actionNoStop());
|
||||
|
||||
filter.conditions(_.map(this.conditions(), (item) => item.cloneSelf()));
|
||||
filter.conditions(this.conditions().map(item => item.cloneSelf()));
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,8 +202,7 @@ class MessageModel extends AbstractModel {
|
|||
getEmails(properties) {
|
||||
return _.compact(
|
||||
_.uniq(
|
||||
_.map(
|
||||
_.reduce(properties, (carry, property) => carry.concat(this[property]), []),
|
||||
_.reduce(properties, (carry, property) => carry.concat(this[property]), []).map(
|
||||
(oItem) => (oItem ? oItem.email : '')
|
||||
)
|
||||
)
|
||||
|
|
@ -628,7 +627,7 @@ class MessageModel extends AbstractModel {
|
|||
* @returns {string}
|
||||
*/
|
||||
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(', ') : '';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue