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
|
|
|
|
2016-11-10 14:22:47 +01: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}}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|