2016-11-26 02:46:55 +08:00
|
|
|
import Users from 'meteor/nova:users';
|
|
|
|
|
2016-08-14 17:59:20 +02:00
|
|
|
if (typeof Package['nova:posts'] !== "undefined") {
|
|
|
|
import Posts from "meteor/nova:posts";
|
2016-08-04 21:54:33 +02:00
|
|
|
|
2016-08-14 17:59:20 +02:00
|
|
|
Posts.views.add("userSubscribedPosts", function (terms) {
|
2016-10-05 08:37:48 +02:00
|
|
|
var user = Users.findOne(terms.userId),
|
2016-08-14 17:59:20 +02:00
|
|
|
postsIds = [];
|
2016-08-04 21:54:33 +02:00
|
|
|
|
2017-01-18 10:18:33 +09:00
|
|
|
if (user && user.subscribedItems && user.subscribedItems.Posts) {
|
|
|
|
postsIds = _.pluck(user.subscribedItems.Posts, "itemId");
|
2016-08-14 17:59:20 +02:00
|
|
|
}
|
2016-08-04 21:54:33 +02:00
|
|
|
|
2016-08-14 17:59:20 +02:00
|
|
|
return {
|
|
|
|
selector: {_id: {$in: postsIds}},
|
|
|
|
options: {limit: 5, sort: {postedAt: -1}}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|