Changes _.filter(array) to native array.filter()

This commit is contained in:
djmaze 2020-07-20 21:29:44 +02:00
parent af136f46c4
commit eb15c6e45f
8 changed files with 30 additions and 32 deletions

View file

@ -75,7 +75,7 @@ class ComposePopupView extends AbstractViewNext {
const identityEmail = identity[name]();
let list = trim(context[name]()).split(/[,]/);
list = _.filter(list, (email) => {
list = list.filter(email => {
email = trim(email);
return email && trim(identityEmail) !== email;
});
@ -225,9 +225,9 @@ class ComposePopupView extends AbstractViewNext {
this.saving = ko.observable(false);
this.attachments = ko.observableArray([]);
this.attachmentsInProcess = ko.computed(() => _.filter(this.attachments(), (item) => item && !item.complete()));
this.attachmentsInReady = ko.computed(() => _.filter(this.attachments(), (item) => item && item.complete()));
this.attachmentsInError = ko.computed(() => _.filter(this.attachments(), (item) => item && '' !== item.error()));
this.attachmentsInProcess = ko.computed(() => this.attachments().filter(item => item && !item.complete()));
this.attachmentsInReady = ko.computed(() => this.attachments().filter(item => item && item.complete()));
this.attachmentsInError = ko.computed(() => this.attachments().filter(item => item && '' !== item.error()));
this.attachmentsCount = ko.computed(() => this.attachments().length);
this.attachmentsInErrorCount = ko.computed(() => this.attachmentsInError().length);
@ -1606,7 +1606,7 @@ class ComposePopupView extends AbstractViewNext {
*/
getAttachmentsDownloadsForUpload() {
return _.map(
_.filter(this.attachments(), (item) => item && '' === item.tempName()),
this.attachments().filter(item => item && '' === item.tempName()),
(item) => item.id
);
}

View file

@ -98,21 +98,20 @@ class ContactsPopupView extends AbstractViewNext {
this.viewSaveTrigger = ko.observable(SaveSettingsStep.Idle);
this.viewPropertiesNames = ko.computed(() =>
_.filter(
this.viewProperties(),
(property) => [ContactPropertyType.FirstName, ContactPropertyType.LastName].includes(property.type())
this.viewProperties().filter(
property => [ContactPropertyType.FirstName, ContactPropertyType.LastName].includes(property.type())
)
);
this.viewPropertiesOther = ko.computed(() =>
_.filter(this.viewProperties(), (property) => [ContactPropertyType.Nick].includes(property.type()))
this.viewProperties().filter(property => [ContactPropertyType.Nick].includes(property.type()))
);
this.viewPropertiesEmails = ko.computed(() =>
_.filter(this.viewProperties(), (property) => ContactPropertyType.Email === property.type())
this.viewProperties().filter(property => ContactPropertyType.Email === property.type())
);
this.viewPropertiesWeb = ko.computed(() =>
_.filter(this.viewProperties(), (property) => ContactPropertyType.Web === property.type())
this.viewProperties().filter(property => ContactPropertyType.Web === property.type())
);
this.viewHasNonEmptyRequiredProperties = ko.computed(() => {
@ -124,11 +123,11 @@ class ContactsPopupView extends AbstractViewNext {
});
this.viewPropertiesPhones = ko.computed(() =>
_.filter(this.viewProperties(), (property) => ContactPropertyType.Phone === property.type())
this.viewProperties().filter(property => ContactPropertyType.Phone === property.type())
);
this.viewPropertiesEmailsNonEmpty = ko.computed(() =>
_.filter(this.viewPropertiesNames(), (property) => '' !== trim(property.value()))
this.viewPropertiesNames().filter(property => '' !== trim(property.value()))
);
const propertyFocused = (property) => {
@ -137,17 +136,17 @@ class ContactsPopupView extends AbstractViewNext {
};
this.viewPropertiesEmailsEmptyAndOnFocused = ko.computed(() =>
_.filter(this.viewPropertiesEmails(), propertyFocused)
this.viewPropertiesEmails().filter(propertyFocused)
);
this.viewPropertiesPhonesEmptyAndOnFocused = ko.computed(() =>
_.filter(this.viewPropertiesPhones(), propertyFocused)
this.viewPropertiesPhones().filter(propertyFocused)
);
this.viewPropertiesWebEmptyAndOnFocused = ko.computed(() => _.filter(this.viewPropertiesWeb(), propertyFocused));
this.viewPropertiesWebEmptyAndOnFocused = ko.computed(() => this.viewPropertiesWeb().filter(propertyFocused));
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(() =>
_.filter(this.viewPropertiesOther(), propertyFocused)
this.viewPropertiesOther().filter(propertyFocused)
);
this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(fFastClearEmptyListHelper);
@ -166,7 +165,7 @@ class ContactsPopupView extends AbstractViewNext {
this.contacts.subscribe(windowResizeCallback);
this.viewProperties.subscribe(windowResizeCallback);
this.contactsChecked = ko.computed(() => _.filter(this.contacts(), (item) => item.checked()));
this.contactsChecked = ko.computed(() => this.contacts().filter(item => item.checked()));
this.contactsCheckedOrSelected = ko.computed(() => {
const checked = this.contactsChecked(),

View file

@ -673,7 +673,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
const checked = this.messageListCheckedOrSelected();
if (0 < checked.length) {
if (isUnd(bFlag)) {
const flagged = _.filter(checked, (message) => message.flagged());
const flagged = checked.filter(message => message.flagged());
this.setAction(
checked[0].folderFullNameRaw,
checked.length === flagged.length ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
@ -693,7 +693,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
const checked = this.messageListCheckedOrSelected();
if (0 < checked.length) {
if (isUnd(seen)) {
const unseen = _.filter(checked, (message) => message.unseen());
const unseen = checked.filter(message => message.unseen());
this.setAction(
checked[0].folderFullNameRaw,
0 < unseen.length ? MessageSetAction.SetSeen : MessageSetAction.UnsetSeen,