diff --git a/app/js/controllers.js b/app/js/controllers.js index 94ca6b8b..49060de7 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1390,31 +1390,29 @@ angular.module('myApp.controllers', ['myApp.i18n']) $timeout(function () { var text = $scope.draftMessage.text; - if (!angular.isString(text) || !text.length) { - return false; - } - - text = text.replace(/:([a-z0-9\-\+\*_]+?):/gi, function (all, name) { - var utfChar = $.emojiarea.reverseIcons[name]; - if (utfChar !== undefined) { - return utfChar; - } - return all; - }); + if (angular.isString(text) && text.length > 0) { + text = text.replace(/:([a-z0-9\-\+\*_]+?):/gi, function (all, name) { + var utfChar = $.emojiarea.reverseIcons[name]; + if (utfChar !== undefined) { + return utfChar; + } + return all; + }); - var timeout = 0; - do { + var timeout = 0; + do { - (function (peerID, curText, curTimeout) { - setTimeout(function () { - AppMessagesManager.sendText(peerID, curText); - }, curTimeout) - })($scope.curDialog.peerID, text.substr(0, 4096), timeout); + (function (peerID, curText, curTimeout) { + setTimeout(function () { + AppMessagesManager.sendText(peerID, curText); + }, curTimeout) + })($scope.curDialog.peerID, text.substr(0, 4096), timeout); - text = text.substr(4096); - timeout += 100; + text = text.substr(4096); + timeout += 100; - } while (text.length); + } while (text.length); + } resetDraft(); $scope.$broadcast('ui_message_send'); diff --git a/app/js/directives.js b/app/js/directives.js index a7738066..dbf5b4b2 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -900,9 +900,11 @@ angular.module('myApp.directives', ['myApp.filters']) .on('keyup', function (e) { updateHeight(); - $scope.$apply(function () { - $scope.draftMessage.text = richTextarea.textContent; - }); + if (!sendAwaiting) { + $scope.$apply(function () { + $scope.draftMessage.text = richTextarea.textContent; + }); + } $timeout.cancel(updatePromise); updatePromise = $timeout(updateValue, 1000); @@ -1032,10 +1034,19 @@ angular.module('myApp.directives', ['myApp.filters']) $scope.$on('ui_history_change', focusField); } - $scope.$on('ui_message_send', focusField); - $scope.$on('ui_peer_draft', updateRichTextarea); - $scope.$on('ui_message_before_send', updateValue); + + var sendAwaiting = false; + $scope.$on('ui_message_before_send', function () { + sendAwaiting = true; + $timeout.cancel(updatePromise); + updateValue(); + }); + $scope.$on('ui_message_send', function () { + sendAwaiting = false; + focusField(); + }); + function focusField () { onContentLoaded(function () { diff --git a/app/partials/desktop/im.html b/app/partials/desktop/im.html index 5ef1a0c6..660562d7 100644 --- a/app/partials/desktop/im.html +++ b/app/partials/desktop/im.html @@ -243,7 +243,7 @@ thumb="ownPhoto" /> -