Browse Source

Maybe fix multiline send bug

master
Igor Zhukov 10 years ago
parent
commit
dfa62f90ce
  1. 40
      app/js/controllers.js
  2. 23
      app/js/directives.js
  3. 2
      app/partials/desktop/im.html
  4. 2
      app/partials/mobile/im.html

40
app/js/controllers.js

@ -1390,31 +1390,29 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -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');

23
app/js/directives.js

@ -900,9 +900,11 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -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']) @@ -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 () {

2
app/partials/desktop/im.html

@ -243,7 +243,7 @@ @@ -243,7 +243,7 @@
thumb="ownPhoto"
/>
</div>
<form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}" ng-submit="sendMessage($event)">
<form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}">
<div class="im_send_field_wrap">
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>

2
app/partials/mobile/im.html

@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
<div class="im_send_form_wrap1">
<div class="im_send_form_wrap clearfix" ng-controller="AppImSendController">
<form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}" ng-submit="sendMessage($event)">
<form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}">
<div class="im_send_field_wrap">
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>

Loading…
Cancel
Save