Skip to content

Commit

Permalink
added message counter to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Aug 29, 2014
1 parent d82c84c commit 35d0eb0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ Object.defineProperty(User, 'collection', {
User.findById = function(id, cb){
var _id = Mongo.ObjectID(id);
User.collection.findOne({_id:_id}, function(err, obj){
cb(err, _.create(User.prototype, obj));
Message.countUnreadForUser(obj._id, function(err2, count){
obj.unreadMessages = count;
console.log('*******user from findById', obj);
cb(err, _.create(User.prototype, obj));
});
});
};

Expand All @@ -35,6 +39,7 @@ User.authenticate = function(o, cb){
if(!isOk){return cb();}
Message.countUnreadForUser(user._id, function(err2, count){
user.unreadMessages = count;
console.log('*******user from authenticate', user);
cb(user);
});
});
Expand Down
2 changes: 1 addition & 1 deletion app/static/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/static/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ body{
.message-text {
margin-top: 10px;
}

.unread {
color: white;
}
1 change: 1 addition & 0 deletions app/views/shared/nav.jade
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ul.nav.navbar-nav.navbar-right
if user
li: a(href='/messages') Messages
li.unread= user.unreadMessages > 0 ? user.unreadMessages : null
li: a(href='/users') Users
li: a(href='/profile') Profile
li
Expand Down

0 comments on commit 35d0eb0

Please sign in to comment.