userAvatar.js 638 B

12345678910111213141516171819202122
  1. Template.userAvatar.helpers({
  2. userData: function() {
  3. if (! this.user) {
  4. this.user = Users.findOne(this.userId);
  5. }
  6. return this.user;
  7. },
  8. memberType: function() {
  9. var userId = this.userId || this.user._id;
  10. var user = Users.findOne(userId);
  11. return user && user.isBoardAdmin() ? 'admin' : 'normal';
  12. },
  13. presenceStatusClassName: function() {
  14. var userPresence = Presences.findOne({ userId: this.user._id });
  15. if (! userPresence)
  16. return 'disconnected';
  17. else if (Session.equals('currentBoard', userPresence.state.currentBoardId))
  18. return 'active';
  19. else
  20. return 'idle';
  21. }
  22. });