mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 12:35:25 +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) {
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user