Browse Source

Maybe fix multiline send bug

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

6
app/js/controllers.js

@ -1390,10 +1390,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$timeout(function () { $timeout(function () {
var text = $scope.draftMessage.text; var text = $scope.draftMessage.text;
if (!angular.isString(text) || !text.length) { if (angular.isString(text) && text.length > 0) {
return false;
}
text = text.replace(/:([a-z0-9\-\+\*_]+?):/gi, function (all, name) { text = text.replace(/:([a-z0-9\-\+\*_]+?):/gi, function (all, name) {
var utfChar = $.emojiarea.reverseIcons[name]; var utfChar = $.emojiarea.reverseIcons[name];
if (utfChar !== undefined) { if (utfChar !== undefined) {
@ -1415,6 +1412,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
timeout += 100; timeout += 100;
} while (text.length); } while (text.length);
}
resetDraft(); resetDraft();
$scope.$broadcast('ui_message_send'); $scope.$broadcast('ui_message_send');

17
app/js/directives.js

@ -900,9 +900,11 @@ angular.module('myApp.directives', ['myApp.filters'])
.on('keyup', function (e) { .on('keyup', function (e) {
updateHeight(); updateHeight();
if (!sendAwaiting) {
$scope.$apply(function () { $scope.$apply(function () {
$scope.draftMessage.text = richTextarea.textContent; $scope.draftMessage.text = richTextarea.textContent;
}); });
}
$timeout.cancel(updatePromise); $timeout.cancel(updatePromise);
updatePromise = $timeout(updateValue, 1000); updatePromise = $timeout(updateValue, 1000);
@ -1032,10 +1034,19 @@ angular.module('myApp.directives', ['myApp.filters'])
$scope.$on('ui_history_change', focusField); $scope.$on('ui_history_change', focusField);
} }
$scope.$on('ui_message_send', focusField);
$scope.$on('ui_peer_draft', updateRichTextarea); $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 () { function focusField () {
onContentLoaded(function () { onContentLoaded(function () {

2
app/partials/desktop/im.html

@ -243,7 +243,7 @@
thumb="ownPhoto" thumb="ownPhoto"
/> />
</div> </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_field_wrap">
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div> <div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>

2
app/partials/mobile/im.html

@ -124,7 +124,7 @@
<div class="im_send_form_wrap1"> <div class="im_send_form_wrap1">
<div class="im_send_form_wrap clearfix" ng-controller="AppImSendController"> <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_field_wrap">
<div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div> <div class="im_send_dropbox_wrap" my-i18n="im_photos_drop_text"></div>

Loading…
Cancel
Save