REFACTOR: Remove _.chain

This commit is contained in:
Robin Ward 2020-09-01 14:12:17 -04:00
parent 71ddcefffa
commit d06deb0c4f
2 changed files with 17 additions and 20 deletions

View File

@ -12,14 +12,11 @@ export default Route.extend({
if (preloadedLogs && preloadedLogs.length) {
// we need to filter out message like: "[SUCCESS]"
// and convert POJOs to Ember Objects
const newLogs = _.chain(preloadedLogs)
.reject(function(log) {
return log.message.length === 0 || log.message[0] === "[";
const newLogs = preloadedLogs
.filter(log => {
return log.message.length > 0 && log.message[0] !== "[";
})
.map(function(log) {
return EmberObject.create(log);
})
.value();
.map(log => EmberObject.create(log));
logs.pushObjects(newLogs);
}
});

View File

@ -429,19 +429,19 @@ const TopicTrackingState = EmberObject.extend({
const subcategoryIds = this.getSubCategoryIds(categoryId);
const mutedCategoryIds =
this.currentUser && this.currentUser.muted_category_ids;
return _.chain(this.states)
.filter(type === "new" ? isNew : isUnread)
.filter(
topic =>
topic.archetype !== "private_message" &&
!topic.deleted &&
(!categoryId || subcategoryIds.has(topic.category_id)) &&
(!tagId || (topic.tags && topic.tags.indexOf(tagId) > -1)) &&
(type !== "new" ||
!mutedCategoryIds ||
mutedCategoryIds.indexOf(topic.category_id) === -1)
)
.value().length;
let filter = type === "new" ? isNew : isUnread;
return Object.values(this.states).filter(
topic =>
filter(topic) &&
topic.archetype !== "private_message" &&
!topic.deleted &&
(!categoryId || subcategoryIds.has(topic.category_id)) &&
(!tagId || (topic.tags && topic.tags.indexOf(tagId) > -1)) &&
(type !== "new" ||
!mutedCategoryIds ||
mutedCategoryIds.indexOf(topic.category_id) === -1)
).length;
},
countNew(categoryId, tagId) {