mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user