Fixed character sheet having undefined data context on refresh

Added waitOn subscriptions and required publications. Expect a warning about autopublish now.
This commit is contained in:
Thaum
2014-11-05 12:35:50 +00:00
parent 1761d71391
commit 5e0a912d21
3 changed files with 15 additions and 1 deletions

View File

@@ -2,9 +2,12 @@ Router.map( function () {
this.route('home',
{
path: '/',
waitOn: function(){
return Meteor.subscribe("characterList", Meteor.userId());
},
data: {
characters: function(){
return Characters.find({owner: Meteor.userId()})
return Characters.find()
}
}
});
@@ -12,6 +15,9 @@ Router.map( function () {
this.route('character', {
path: '/character/:_id',
notFoundTemplate: 'characterNotFound',
waitOn: function(){
return Meteor.subscribe("singleCharacter", this.params._id, Meteor.userId());
},
data: function() {
var data = Characters.findOne({_id: this.params._id});
return data;

View File

@@ -0,0 +1,4 @@
Meteor.publish("characterList",function(userId){
//TODO also return characters this user can view
return Characters.find({owner: userId});
});

View File

@@ -0,0 +1,4 @@
Meteor.publish("singleCharacter", function(characterId, userId){
//TODO check if this characer can be viewed by this user
return Characters.find({_id: characterId});
});