mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:50:23 +08:00
REFACTOR: Remove _.chain
This commit is contained in:
parent
71ddcefffa
commit
d06deb0c4f
|
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user