diff --git a/app/js/controllers.js b/app/js/controllers.js index 21e35461..acc6b7c9 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -973,7 +973,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) .controller('AppImHistoryController', function ($scope, $location, $timeout, $rootScope, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ApiUpdatesManager, PeersSelectService, IdleManager, StatusManager, ErrorService) { - $scope.$watch('curDialog', applyDialogSelect); + $scope.$watchCollection('curDialog', applyDialogSelect); ApiUpdatesManager.attach(); IdleManager.start(); @@ -993,6 +993,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.selectedReply = selectedReply; $scope.selectedCancel = selectedCancel; $scope.selectedFlush = selectedFlush; + $scope.botStart = botStart; $scope.toggleEdit = toggleEdit; $scope.toggleMedia = toggleMedia; @@ -1043,8 +1044,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.curDialog.peerID = peerID; $scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer); $scope.historyFilter.mediaType = false; - $scope.historyState.startBot = newDialog.startParam ? 1 : false; + updateStartBot(); selectedCancel(true); if (oldDialog.peer && @@ -1138,6 +1139,33 @@ angular.module('myApp.controllers', ['myApp.i18n']) } } + function updateStartBot () { + if (!peerID || + peerID < 0 || + !AppUsersManager.isBot(peerID) || + $scope.historyFilter.mediaType || + $scope.curDialog.messageID) { + $scope.historyState.startBot = false; + } + else if ( + $scope.state.empty || ( + peerHistory && + peerHistory.messages.length == 1 && + peerHistory.messages[0].action && + peerHistory.messages[0].action._ == 'messageActionBotIntro' + ) + ) { + $scope.historyState.startBot = 2; + } + else if ($scope.curDialog.startParam) { + $scope.historyState.startBot = 1; + } + else { + $scope.historyState.startBot = false; + } + $scope.$broadcast('ui_panel_update'); + } + function messageFocusHistory () { var history = historiesQueueFind(peerID); @@ -1340,29 +1368,13 @@ angular.module('myApp.controllers', ['myApp.i18n']) AppMessagesManager.readHistory($scope.curDialog.inputPeer); - if (!$scope.curDialog.messageID && - !inputMediaFilter && - peerID > 0 && - AppUsersManager.isBot(peerID) && - (!peerHistory.ids.length || peerHistory.ids.length == 1 && peerHistory.ids[0] < 0) - ) { - $scope.historyState.startBot = 2; - } + updateStartBot(); }, function () { safeReplaceObject($scope.state, {error: true}); }); } - $scope.botStartCancel = function () { - delete $scope.curDialog.startParam; - } - - $scope.botStart = function () { - AppMessagesManager.startBot(peerID, 0, $scope.curDialog.startParam); - delete $scope.curDialog.startParam; - } - function showEmptyHistory () { jump++; safeReplaceObject($scope.historyPeer, {}); @@ -1373,6 +1385,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.$broadcast('ui_history_change'); } + function botStart () { + AppMessagesManager.startBot(peerID, 0, $scope.curDialog.startParam); + $scope.curDialog.startParam = false; + } + function toggleMessage (messageID, $event) { var target = $event.target, shiftClick = $event.shiftKey; @@ -1430,6 +1447,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) } function selectedCancel (noBroadcast) { + if (!noBroadcast && + $scope.curDialog.startParam) { + delete $scope.curDialog.startParam; + return; + } $scope.selectedMsgs = {}; $scope.selectedCount = 0; $scope.historyState.selectActions = false; @@ -1692,6 +1714,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) AppMessagesManager.readHistory($scope.curDialog.inputPeer); }); } + + updateStartBot(); } }); @@ -1721,6 +1745,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.$broadcast('messages_regroup'); if (historyUpdate.peerID == $scope.curDialog.peerID) { $scope.state.empty = !newMessages.length; + updateStartBot(); } }); @@ -1731,6 +1756,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) history.ids = []; if (dialog.peerID == $scope.curDialog.peerID) { $scope.state.empty = true; + updateStartBot(); } } }); diff --git a/app/js/services.js b/app/js/services.js index 3ae51bf9..ad3972d5 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -1107,7 +1107,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return AppProfileManager.getProfile(peerID).then(function (userFull) { var description = userFull.bot_info && userFull.bot_info.description; if (description) { - var messageID = tempID-- + var messageID = tempID--; var message = { _: 'messageService', id: messageID, @@ -2896,6 +2896,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } } historyStorage.history = newHistory; + if (updatedData.count && + historyStorage.count !== null && + historyStorage.count > 0) { + historyStorage.count -= updatedData.count; + if (historyStorage.count < 0) { + historyStorage.count = 0; + } + } for (var i = 0; i < historyStorage.pending.length; i++) { if (!updatedData.msgs[historyStorage.pending[i]]) { @@ -4293,8 +4301,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) syncPending.ptsAwaiting = true; return false; } - curState.pts = update.pts; - popPts = true; + if (update.pts > curState.pts) { + curState.pts = update.pts; + popPts = true; + } } else if (options.seq > 0) { var seq = options.seq; diff --git a/app/less/app.less b/app/less/app.less index ced11974..58a541d9 100644 --- a/app/less/app.less +++ b/app/less/app.less @@ -3046,13 +3046,6 @@ a.contacts_modal_contact:hover .md_modal_list_peer_description, } } -.im_edit_panel_title { - text-align: center; - margin: 0; - font-size: 14px; - line-height: 34px; -} - .im_message_focus { .im_message_date, .im_message_document_size, diff --git a/app/less/desktop.less b/app/less/desktop.less index 55435f88..37e52c0e 100644 --- a/app/less/desktop.less +++ b/app/less/desktop.less @@ -823,7 +823,8 @@ a.footer_link.active:active { .im { &_edit_delete_btn, &_edit_forward_btn, - &_edit_reply_btn { + &_edit_reply_btn, + &_start_btn { border-radius: 2px; padding: 7px 17px; font-weight: bold; @@ -857,6 +858,14 @@ a.footer_link.active:active { text-transform: uppercase; } + &_edit_start_actions { + text-align: center; + text-transform: uppercase; + } + &_start_btn { + padding: 7px 25px; + } + &_selected_count { color: #b9cfe3; } diff --git a/app/partials/desktop/im.html b/app/partials/desktop/im.html index 39883689..233cdbee 100644 --- a/app/partials/desktop/im.html +++ b/app/partials/desktop/im.html @@ -140,10 +140,13 @@
-
+
- -
+ +
+ +
+
@@ -151,14 +154,6 @@
-
-
- -
- -
-
-