|
|
@ -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) { |
|
|
|
.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(); |
|
|
|
ApiUpdatesManager.attach(); |
|
|
|
IdleManager.start(); |
|
|
|
IdleManager.start(); |
|
|
@ -993,6 +993,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.selectedReply = selectedReply; |
|
|
|
$scope.selectedReply = selectedReply; |
|
|
|
$scope.selectedCancel = selectedCancel; |
|
|
|
$scope.selectedCancel = selectedCancel; |
|
|
|
$scope.selectedFlush = selectedFlush; |
|
|
|
$scope.selectedFlush = selectedFlush; |
|
|
|
|
|
|
|
$scope.botStart = botStart; |
|
|
|
|
|
|
|
|
|
|
|
$scope.toggleEdit = toggleEdit; |
|
|
|
$scope.toggleEdit = toggleEdit; |
|
|
|
$scope.toggleMedia = toggleMedia; |
|
|
|
$scope.toggleMedia = toggleMedia; |
|
|
@ -1043,8 +1044,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.curDialog.peerID = peerID; |
|
|
|
$scope.curDialog.peerID = peerID; |
|
|
|
$scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer); |
|
|
|
$scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer); |
|
|
|
$scope.historyFilter.mediaType = false; |
|
|
|
$scope.historyFilter.mediaType = false; |
|
|
|
$scope.historyState.startBot = newDialog.startParam ? 1 : false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateStartBot(); |
|
|
|
selectedCancel(true); |
|
|
|
selectedCancel(true); |
|
|
|
|
|
|
|
|
|
|
|
if (oldDialog.peer && |
|
|
|
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 () { |
|
|
|
function messageFocusHistory () { |
|
|
|
var history = historiesQueueFind(peerID); |
|
|
|
var history = historiesQueueFind(peerID); |
|
|
|
|
|
|
|
|
|
|
@ -1340,29 +1368,13 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|
|
|
|
|
|
|
|
|
if (!$scope.curDialog.messageID && |
|
|
|
updateStartBot(); |
|
|
|
!inputMediaFilter && |
|
|
|
|
|
|
|
peerID > 0 && |
|
|
|
|
|
|
|
AppUsersManager.isBot(peerID) && |
|
|
|
|
|
|
|
(!peerHistory.ids.length || peerHistory.ids.length == 1 && peerHistory.ids[0] < 0) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
$scope.historyState.startBot = 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, function () { |
|
|
|
}, function () { |
|
|
|
safeReplaceObject($scope.state, {error: true}); |
|
|
|
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 () { |
|
|
|
function showEmptyHistory () { |
|
|
|
jump++; |
|
|
|
jump++; |
|
|
|
safeReplaceObject($scope.historyPeer, {}); |
|
|
|
safeReplaceObject($scope.historyPeer, {}); |
|
|
@ -1373,6 +1385,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$broadcast('ui_history_change'); |
|
|
|
$scope.$broadcast('ui_history_change'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function botStart () { |
|
|
|
|
|
|
|
AppMessagesManager.startBot(peerID, 0, $scope.curDialog.startParam); |
|
|
|
|
|
|
|
$scope.curDialog.startParam = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function toggleMessage (messageID, $event) { |
|
|
|
function toggleMessage (messageID, $event) { |
|
|
|
var target = $event.target, |
|
|
|
var target = $event.target, |
|
|
|
shiftClick = $event.shiftKey; |
|
|
|
shiftClick = $event.shiftKey; |
|
|
@ -1430,6 +1447,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function selectedCancel (noBroadcast) { |
|
|
|
function selectedCancel (noBroadcast) { |
|
|
|
|
|
|
|
if (!noBroadcast && |
|
|
|
|
|
|
|
$scope.curDialog.startParam) { |
|
|
|
|
|
|
|
delete $scope.curDialog.startParam; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
$scope.selectedMsgs = {}; |
|
|
|
$scope.selectedMsgs = {}; |
|
|
|
$scope.selectedCount = 0; |
|
|
|
$scope.selectedCount = 0; |
|
|
|
$scope.historyState.selectActions = false; |
|
|
|
$scope.historyState.selectActions = false; |
|
|
@ -1692,6 +1714,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateStartBot(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -1721,6 +1745,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$broadcast('messages_regroup'); |
|
|
|
$scope.$broadcast('messages_regroup'); |
|
|
|
if (historyUpdate.peerID == $scope.curDialog.peerID) { |
|
|
|
if (historyUpdate.peerID == $scope.curDialog.peerID) { |
|
|
|
$scope.state.empty = !newMessages.length; |
|
|
|
$scope.state.empty = !newMessages.length; |
|
|
|
|
|
|
|
updateStartBot(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -1731,6 +1756,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
history.ids = []; |
|
|
|
history.ids = []; |
|
|
|
if (dialog.peerID == $scope.curDialog.peerID) { |
|
|
|
if (dialog.peerID == $scope.curDialog.peerID) { |
|
|
|
$scope.state.empty = true; |
|
|
|
$scope.state.empty = true; |
|
|
|
|
|
|
|
updateStartBot(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|