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) { if (preloadedLogs && preloadedLogs.length) {
// we need to filter out message like: "[SUCCESS]" // we need to filter out message like: "[SUCCESS]"
// and convert POJOs to Ember Objects // and convert POJOs to Ember Objects
const newLogs = _.chain(preloadedLogs) const newLogs = preloadedLogs
.reject(function(log) { .filter(log => {
return log.message.length === 0 || log.message[0] === "["; return log.message.length > 0 && log.message[0] !== "[";
}) })
.map(function(log) { .map(log => EmberObject.create(log));
return EmberObject.create(log);
})
.value();
logs.pushObjects(newLogs); logs.pushObjects(newLogs);
} }
}); });

View File

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