Created
November 10, 2013 09:34
-
-
Save GVRV/7396016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.startup(function () { | |
Deps.autorun(function () { | |
var selected = Session.get("selected"); | |
if (selected) { | |
var hiive = Hiives.findOne(selected); | |
if (hiive) { | |
Meteor.subscribe("messages", hiive._id); | |
Meteor.subscribe("activeUsers", hiive._id); | |
} | |
} | |
}); | |
}); | |
Template.attendance.activeUsers = function () { | |
return activeUsers.find(); //activeUsers is undefined! Even though Session.get("selected") changed from null to something. | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish('activeUsers', function(hiiveId) { | |
Meteor.call('canAccessHiive', hiiveId); | |
check(hiiveId, String); | |
// Setup some filter to find the users your logged in user | |
// cares about. It's unlikely that you want to publish the | |
// presences of _all_ the users in the system. | |
var filter = { | |
'state.hiive': hiiveId | |
}; | |
console.log(Meteor.presences.find(filter, {fields: {state: true, userId: true}})); | |
// ProTip: unless you need it, don't send lastSeen down as it'll make your | |
// templates constantly re-render (and use bandwidth) | |
return Meteor.presences.find(filter, {fields: {state: true, userId: true}}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment