mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
fix #1740
This commit is contained in:
@@ -80,14 +80,16 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A
|
|||||||
|
|
||||||
.controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){
|
.controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){
|
||||||
$scope._chatMessage = '';
|
$scope._chatMessage = '';
|
||||||
|
$scope._sending = false;
|
||||||
|
|
||||||
$scope.postChat = function(group, message){
|
$scope.postChat = function(group, message){
|
||||||
if (_.isEmpty(message)) return
|
console.log($scope._sending)
|
||||||
$('.chat-btn').addClass('disabled');
|
if (_.isEmpty(message) || $scope._sending) return;
|
||||||
|
$scope._sending = true;
|
||||||
group.$postChat({message:message}, function(data){
|
group.$postChat({message:message}, function(data){
|
||||||
$scope._chatMessage = '';
|
|
||||||
group.chat = data.chat;
|
group.chat = data.chat;
|
||||||
$('.chat-btn').removeClass('disabled');
|
$scope._chatMessage = '';
|
||||||
|
$scope._sending = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,9 +210,6 @@ api.postChat = function(req, res, next) {
|
|||||||
timestamp: +(new Date)
|
timestamp: +(new Date)
|
||||||
};
|
};
|
||||||
|
|
||||||
// workaround for preventing duplicate chat messages. Real solution is to prevent <ENTER> between sends on the client
|
|
||||||
if (group.chat[0].uuid == message.uuid && group.chat[0].text == message.text) return res.json(group);
|
|
||||||
|
|
||||||
group.chat.unshift(message);
|
group.chat.unshift(message);
|
||||||
group.chat.splice(200);
|
group.chat.splice(200);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ form(ng-submit='postChat(group,_chatMessage)')
|
|||||||
table.pull-right
|
table.pull-right
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
input.btn.chat-btn(type='submit', value='Send Chat')
|
input.btn.chat-btn(type='submit', value='Send Chat', ng-class='{disabled: _sending == true}')
|
||||||
td
|
td
|
||||||
button.btn(type="button", ng-click='sync(group)', tooltip='Fetch Recent Messages')
|
button.btn(type="button", ng-click='sync(group)', tooltip='Fetch Recent Messages')
|
||||||
i(class='pull-right icon-refresh')
|
i(class='pull-right icon-refresh')
|
||||||
|
|||||||
Reference in New Issue
Block a user