You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Meteor.publishComposite('allPostsWithComments', {
find: function(){
return Posts.find({"status.deleted": false}, POST_OPTIONS);
},
children: [
{
// find related post owner
find: function(post, activity){
return Meteor.users.find({_id: post.user_id }, USER_OPTIONS );
},
},
{
// find related post comments
find: function(post, activity){
return Comments.find( { post_id: post._id, "status.deleted": false } );
}
},
]
});
Meteor.publishComposite('onePost', function(postId) {
return {
find: function() {
// Find posts made by user. Note arguments for callback function
// being used in query.
return Posts.find({ _id: postId }, POST_OPTIONS);
},
children: [
{
find: function(post){
// publish post owner
return Meteor.users.find({_id: post.user_id}, USER_OPTIONS);
},
},
{
find: function(post){
// publish post comments
return Comments.find({post_id: post._id, "status.deleted": false});
},
children: [
{
find: function(comment, post){
// publish users related to comments
return Meteor.users.find({_id: comment.user_id}, USER_OPTIONS);
}
}
]
}
]
}
});
And two routes:
this.route('explore', {
waitOn: function () {
// return one handle, a function, or an array
return [
subsManager.subscribe('allPostsWithComments'),
];
},
});
this.route('postShow', {
path: '/post/:_id',
waitOn: function () {
return [
subsManager.subscribe('onePost', this.params._id),
];
},
data: function () {
return { post: Posts.findOne({_id: this.params._id}) };
},
yieldRegions: {
'_postOptions': {to: 'options'},
'_headerBack': {to: 'header'},
'_newCommentFooter': {to: 'footer'},
},
});
As you can see in this scenario in "onePost" publication I'm not filtering posts by "status.deleted: false". That's because I want to publish deleted post only to "postShow" route and if it's deleted, I'm showing manual message to user: "This post has been deleted".
But I do filter by "status.deleted: false" on "explore" page as you can see in "allPostsWithComments" publish.
Now here's the problem: when I delete the post in "postShow" page, it's showing correctly deleted message and redirects me back to "explore" page and the currently deleted post is shown there and in all other routes as well for my current user until I hit refresh in my browser!. It's working normally for other users and the post disappears from their "explore" page when it's getting deleted. It's also working normally for my current user only after I hit refresh page.
PS: I tried navigating with Iron Router through both Router.go() and <a href="/explore"></a> and result is the same.
The text was updated successfully, but these errors were encountered:
v3rron
changed the title
Publications are leaking to other routes for current user...
Publications are leaking to other routes for current user
Aug 8, 2015
v3rron
changed the title
Publications are leaking to other routes for current user
Publications are leaking(!) to other routes for current user
Aug 8, 2015
I actually figured it out. :) It turned out to be subsManager package which was basically caching the subscriptions on the client.
Just needed to change from subsManager.subscribe('onePost') to Meteor.subscribe('onePost') and everything works like a charm.
I have two publications:
And two routes:
As you can see in this scenario in "onePost" publication I'm not filtering posts by "status.deleted: false". That's because I want to publish deleted post only to "postShow" route and if it's deleted, I'm showing manual message to user: "This post has been deleted".
But I do filter by "status.deleted: false" on "explore" page as you can see in "allPostsWithComments" publish.
Now here's the problem: when I delete the post in "postShow" page, it's showing correctly deleted message and redirects me back to "explore" page and the currently deleted post is shown there and in all other routes as well for my current user until I hit refresh in my browser!. It's working normally for other users and the post disappears from their "explore" page when it's getting deleted. It's also working normally for my current user only after I hit refresh page.
PS: I tried navigating with Iron Router through both Router.go() and
<a href="/explore"></a>
and result is the same.The text was updated successfully, but these errors were encountered: