0

Im building an app which sends questions to users, at a specific time. Most of the times everything goes well, and the question appears at the right time on my screen.

But now I'm testing it with Firefox and on my Android device. I'm getting a push notification (on my phone) at the right time, but when I open the app, it still says I dont have any open questions. Same on firefox. When I refresh my internetbrowser, and when I restart the app on my phone, the questions have shown up.

I think this has something to do with the cache of the Meteor app? Does anyone know a proper solution to fix this issue? Or does this only happen when I run my app locally?

My publication looks like this:

Meteor.publish("questions", function () {
var currentUser = this.userId;
if (Roles.userIsInRole(currentUser, ['superadmin']) || Roles.userIsInRole(currentUser, ['admin'])){
    return Questions.find({});
}
else if(!this.userId){
    return null;
}
else{
    var joinedProjects = Projects.find({
    $or: [
      {invited: { $in: [currentUser] }},
          {accepted: { $in: [currentUser] }}
    ]
    }).map(function (projects) { return projects._id; });
    return Questions.find({  project: { $in: joinedProjects }});
}
});
coder14
  • 223
  • 1
  • 4
  • 14
  • 1
    I would guess that you are publishing data that depends on other data you are querying within your publication. If that is the case, you will need to perform a reactive publication, reactive join or change your data model. – MasterAM Jan 19 '17 at 14:18
  • I've added my publication to the question – coder14 Jan 19 '17 at 14:32
  • Your question is very similar to [this](http://stackoverflow.com/q/37632033/268093), [that](http://stackoverflow.com/q/41605650/268093) and several others. The answers to them suggest multiple solutions, mainly `publish-composite` and `reactive-publish`. You also don't need the $in clause (i.e, use `{invited: currentUser}` in your query). – MasterAM Jan 20 '17 at 06:56

0 Answers0