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:
@@ -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;
|
||||
|
||||
4
rpg-docs/server/publications/characterList.js
Normal file
4
rpg-docs/server/publications/characterList.js
Normal file
@@ -0,0 +1,4 @@
|
||||
Meteor.publish("characterList",function(userId){
|
||||
//TODO also return characters this user can view
|
||||
return Characters.find({owner: userId});
|
||||
});
|
||||
4
rpg-docs/server/publications/singleCharacter.js
Normal file
4
rpg-docs/server/publications/singleCharacter.js
Normal 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});
|
||||
});
|
||||
Reference in New Issue
Block a user