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) {
|
|
|
|
var user = Meteor.users.findOne(terms.userId),
|
|
|
|
postsIds = [];
|
2016-08-04 21:54:33 +02:00
|
|
|
|
2016-08-14 17:59:20 +02:00
|
|
|
if (user && user.telescope.subscribedItems && user.telescope.subscribedItems.Posts) {
|
|
|
|
postsIds = _.pluck(user.telescope.subscribedItems.Posts, "itemId");
|
|
|
|
}
|
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}}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|