diff --git a/app/js/controllers.js b/app/js/controllers.js index 0bc57246..12d27efa 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2348,6 +2348,22 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.$broadcast('ui_peer_draft'); }); } + else if (attachment._ == 'inline_query') { + var mention = attachment.mention; + var query = attachment.query; + forceDraft = $scope.curDialog.peer; + + $timeout(function () { + $scope.draftMessage.text = mention + ' ' + query; + $scope.$broadcast('ui_peer_draft', { + customSelection: [ + mention + " " + query, + '', + '' + ] + }); + }, 1000); + } } function replySelect(messageID) { diff --git a/app/js/directives.js b/app/js/directives.js index 662cd089..50300c9a 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -176,7 +176,7 @@ angular.module('myApp.directives', ['myApp.filters']) } }) - .directive('myMessageBody', function($compile, AppPeersManager, AppChatsManager, AppUsersManager, AppMessagesManager, RichTextProcessor) { + .directive('myMessageBody', function($compile, AppPeersManager, AppChatsManager, AppUsersManager, AppMessagesManager, AppInlineBotsManager, RichTextProcessor) { var messageMediaCompiled = $compile('
'); var messageKeyboardCompiled = $compile(''); @@ -246,12 +246,20 @@ angular.module('myApp.directives', ['myApp.filters']) }); scope.$on('reply_inline_button_press', function (e, button) { - AppMessagesManager.replyMarkupButtonPress(message.mid, button); + switch (button._) { + case 'keyboardButtonSwitchInline': + AppInlineBotsManager.switchInlineButtonClick(message.mid, button); + break; + case 'keyboardButtonCallback': + AppInlineBotsManager.callbackButtonClick(message.mid, button); + break; + } }); } function link ($scope, element, attrs) { var message = $scope.message; + message.dir = true; var msgID = message.mid; updateMessageText($scope, element, message); @@ -268,14 +276,18 @@ angular.module('myApp.directives', ['myApp.filters']) } $scope.$on('message_edit', function (e, data) { - if (data.mid != msgID) { + // var message = $scope.message; + // message = $scope.$parent.$eval(attrs.myMessageBody); + message = AppMessagesManager.wrapForHistory(message.mid); + if (data.mid != message.mid) { return; } - console.log('after edit', message); + console.log('after edit', message.dir, message); updateMessageText($scope, element, message); updateMessageMedia($scope, element, message); updateMessageKeyboard($scope, element, message); $scope.$emit('ui_height'); + message.dir = true; }); } }) @@ -323,7 +335,7 @@ angular.module('myApp.directives', ['myApp.filters']) classPrefix: 'reply_markup', maxHeight: 170 }); - $scope.buttonSend = function (button) { + $scope.buttonClick = function (button) { $scope.$emit('reply_button_press', button); } @@ -458,7 +470,7 @@ angular.module('myApp.directives', ['myApp.filters']) }; function link ($scope, element, attrs) { - $scope.buttonSend = function (button) { + $scope.buttonClick = function (button) { $scope.$emit('reply_inline_button_press', button); } } diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index 60e15277..228683be 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -1742,7 +1742,6 @@ angular.module('izhukov.utils', []) } function wrapUrl(url, unsafe) { - var url = entity.url || entityText; if (!url.match(/^https?:\/\//i)) { url = 'http://' + url; } diff --git a/app/js/lib/utils.js b/app/js/lib/utils.js index b59eb0d8..6719426b 100644 --- a/app/js/lib/utils.js +++ b/app/js/lib/utils.js @@ -164,7 +164,10 @@ function getRichValue(field) { lines.push(line.join('')); } - return lines.join('\n'); + var value = lines.join('\n'); + value = value.replace(/\u00A0/g, ' '); + + return value; } function getRichValueWithCaret(field) { @@ -197,6 +200,7 @@ function getRichValueWithCaret(field) { if (caretPos != -1) { value = value.substr(0, caretPos) + value.substr(caretPos + 1); } + value = value.replace(/\u00A0/g, ' '); return [value, caretPos]; } diff --git a/app/js/message_composer.js b/app/js/message_composer.js index 530b361b..b88f4679 100644 --- a/app/js/message_composer.js +++ b/app/js/message_composer.js @@ -978,7 +978,6 @@ MessageComposer.prototype.checkAutocomplete = function (forceFull) { if (value && this.curInlineResults && this.curInlineResults.text == value) { - console.trace(dT(), value, this.curInlineResults); this.showInlineSuggestions(this.curInlineResults); return; }; @@ -1335,7 +1334,6 @@ MessageComposer.prototype.onChange = function (e) { if (this.richTextareaEl) { delete this.keyupStarted; var richValue = getRichValue(this.richTextareaEl[0]); - richValue = richValue.replace(/\u00A0/g, ' '); this.textareaEl.val(richValue).trigger('change'); } this.updateInlinePlaceholder(); @@ -1390,13 +1388,18 @@ MessageComposer.prototype.setFocusedValue = function (parts) { MessageComposer.prototype.getRichHtml = function (text) { - return $('