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

@ -50,7 +50,7 @@ class Selector {
) {
this.list = koList;
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({ rateLimit: 0 });
this.listChecked = ko.computed(() => this.list().filter(item => item.checked())).extend({ rateLimit: 0 });
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
this.focusedItem = koFocusedItem || ko.observable(null);

View file

@ -19,13 +19,13 @@ class PackagesAdminSettings {
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = ko.computed(() =>
_.filter(this.packages(), (item) => item && '' !== item.installed && !item.compare)
this.packages().filter(item => item && '' !== item.installed && !item.compare)
);
this.packagesAvailableForUpdate = ko.computed(() =>
_.filter(this.packages(), (item) => item && '' !== item.installed && !!item.compare)
this.packages().filter(item => item && '' !== item.installed && !!item.compare)
);
this.packagesAvailableForInstallation = ko.computed(() =>
_.filter(this.packages(), (item) => item && '' === item.installed)
this.packages().filter(item => item && '' === item.installed)
);
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));

View file

@ -1,11 +1,10 @@
import _ from '_';
import ko from 'ko';
class DomainAdminStore {
constructor() {
this.domains = ko.observableArray([]);
this.domains.loading = ko.observable(false).extend({ 'throttle': 100 });
this.domainsWithoutAliases = ko.computed(() => _.filter(this.domains(), (item) => item && !item.alias));
this.domainsWithoutAliases = ko.computed(() => this.domains().filter(item => item && !item.alias));
}
}

View file

@ -142,7 +142,7 @@ class MessageUserStore {
this.isMessageSelected = ko.computed(() => null !== this.message());
this.messageListChecked = ko
.computed(() => _.filter(this.messageList(), (item) => item.checked()))
.computed(() => this.messageList().filter(item => item.checked()))
.extend({ rateLimit: 0 });
this.hasCheckedMessages = ko.computed(() => 0 < this.messageListChecked().length).extend({ rateLimit: 0 });
@ -307,7 +307,7 @@ class MessageUserStore {
currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(),
messages =
currentFolderFullNameRaw === fromFolderFullNameRaw
? _.filter(messageList, (item) => item && uidForRemove.includes(pInt(item.uid)))
? messageList.filter(item => item && uidForRemove.includes(pInt(item.uid)))
: [];
_.each(messages, (item) => {

View file

@ -18,8 +18,8 @@ class PgpUserStore {
this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null;
this.openpgpkeysPublic = ko.computed(() => _.filter(this.openpgpkeys(), (item) => !!(item && !item.isPrivate)));
this.openpgpkeysPrivate = ko.computed(() => _.filter(this.openpgpkeys(), (item) => !!(item && item.isPrivate)));
this.openpgpkeysPublic = ko.computed(() => this.openpgpkeys().filter(item => !!(item && !item.isPrivate)));
this.openpgpkeysPrivate = ko.computed(() => this.openpgpkeys().filter(item => !!(item && item.isPrivate)));
}
/**
@ -124,7 +124,7 @@ class PgpUserStore {
* @returns {?}
*/
findAllPublicKeysByEmailNotNative(email) {
return _.filter(this.openpgpkeysPublic(), (item) => item && -1 < item.emails.indexOf(email)) || null;
return this.openpgpkeysPublic().filter(item => item && -1 < item.emails.indexOf(email)) || null;
}
/**
@ -132,7 +132,7 @@ class PgpUserStore {
* @returns {?}
*/
findAllPrivateKeysByEmailNotNative(email) {
return _.filter(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email)) || null;
return this.openpgpkeysPrivate().filter(item => item && -1 < item.emails.indexOf(email)) || null;
}
/**

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,