chat: add +1 (like) to messages. @snicker does views/options/social/chat-message.jade flag you for any performance issues which should be optimized with bindonce? (I'm still a bit of a bo-noob)

This commit is contained in:
Tyler Renelle
2014-01-05 22:10:34 -07:00
parent 95516f709c
commit f6e6d115ac
7 changed files with 76 additions and 9 deletions

View File

@@ -127,7 +127,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
});
}])
.controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){
.controller('ChatCtrl', ['$scope', 'Groups', 'User', '$http', 'API_URL', 'Notification', function($scope, Groups, User, $http, API_URL, Notification){
$scope.message = {content:''};
$scope._sending = false;
@@ -178,6 +178,20 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
}
}
$scope.likeChatMessage = function(group,message) {
if (message.uuid == User.user._id)
return Notification.text("Can't like your own message. Don't be that person.");
if (!message.likes) message.likes = {};
if (message.likes[User.user._id]) {
delete message.likes[User.user._id];
} else {
message.likes[User.user._id] = true;
}
//Chat.Chat.like({gid:group._id,mid:message.id});
$http.post(API_URL + '/api/v2/groups/' + group._id + '/chat/' + message.id + '/like');
}
$scope.sync = function(group){
group.$get();
}