diff --git a/app/js/controllers.js b/app/js/controllers.js index 99774036..17ac8a0d 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -913,9 +913,18 @@ angular.module('myApp.controllers', []) return all; }); + var timeout = 0; do { - AppMessagesManager.sendText($scope.curDialog.peerID, text.substr(0, 4096)); + + (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; + } while (text.length); resetDraft(); diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index a2a42976..b602f447 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -2623,7 +2623,7 @@ factory('MtpApiManager', function (AppConfigManager, MtpAuthorizer, MtpNetworker if (!options.noErrorBox) { error.input = method; - error.stack = error.stack || stack; + error.stack = error.stack || (new Error()).stack; setTimeout(function () { if (!error.handled) { ErrorService.show({error: error}); diff --git a/app/js/services.js b/app/js/services.js index fcb5927e..9b699058 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -1191,9 +1191,6 @@ angular.module('myApp.services', []) message: text, random_id: randomID }, sentRequestOptions).then(function (result) { - if (pendingAfterMsgs[peerID] === sentRequestOptions) { - delete pendingAfterMsgs[peerID]; - } if (ApiUpdatesManager.saveSeq(result.seq)) { ApiUpdatesManager.saveUpdate({ _: 'updateMessageID', @@ -1211,6 +1208,10 @@ angular.module('myApp.services', []) } }, function (error) { toggleError(true); + })['finally'](function () { + if (pendingAfterMsgs[peerID] === sentRequestOptions) { + delete pendingAfterMsgs[peerID]; + } }); pendingAfterMsgs[peerID] = sentRequestOptions; @@ -1475,6 +1476,8 @@ angular.module('myApp.services', []) } function forwardMessages (peerID, msgIDs) { + msgIDs = $filter('orderBy')(msgIDs); + return MtpApiManager.invokeApi('messages.forwardMessages', { peer: AppPeersManager.getInputPeerByID(peerID), id: msgIDs