|
|
@ -2081,7 +2081,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$on('user_update', angular.noop); |
|
|
|
$scope.$on('user_update', angular.noop); |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
.controller('AppImSendController', function ($scope, $timeout, MtpApiManager, Storage, AppProfileManager, AppChatsManager, AppUsersManager, AppPeersManager, AppDocsManager, AppMessagesManager, AppInlineBotsManager, MtpApiFileManager, RichTextProcessor) { |
|
|
|
.controller('AppImSendController', function ($q, $scope, $timeout, MtpApiManager, Storage, AppProfileManager, AppChatsManager, AppUsersManager, AppPeersManager, AppDocsManager, AppMessagesManager, AppInlineBotsManager, MtpApiFileManager, RichTextProcessor) { |
|
|
|
|
|
|
|
|
|
|
|
$scope.$watch('curDialog.peer', resetDraft); |
|
|
|
$scope.$watch('curDialog.peer', resetDraft); |
|
|
|
$scope.$on('user_update', angular.noop); |
|
|
|
$scope.$on('user_update', angular.noop); |
|
|
@ -2117,6 +2117,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$broadcast('ui_peer_draft', {focus: true}); |
|
|
|
$scope.$broadcast('ui_peer_draft', {focus: true}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('inline_bots_popular', updateMentions); |
|
|
|
|
|
|
|
|
|
|
|
$scope.replyKeyboardToggle = replyKeyboardToggle; |
|
|
|
$scope.replyKeyboardToggle = replyKeyboardToggle; |
|
|
|
$scope.toggleSlash = toggleSlash; |
|
|
|
$scope.toggleSlash = toggleSlash; |
|
|
|
|
|
|
|
|
|
|
@ -2163,19 +2165,45 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
function updateMentions () { |
|
|
|
function updateMentions () { |
|
|
|
var peerID = $scope.curDialog.peerID; |
|
|
|
var peerID = $scope.curDialog.peerID; |
|
|
|
|
|
|
|
|
|
|
|
if (!peerID || peerID > 0) { |
|
|
|
if (!peerID) { |
|
|
|
safeReplaceObject($scope.mentions, {}); |
|
|
|
safeReplaceObject($scope.mentions, {}); |
|
|
|
$scope.$broadcast('mentions_update'); |
|
|
|
$scope.$broadcast('mentions_update'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
AppProfileManager.getChatFull(-peerID).then(function (chatFull) { |
|
|
|
|
|
|
|
var participantsVector = (chatFull.participants || {}).participants || []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mentionUsers = []; |
|
|
|
var mentionUsers = []; |
|
|
|
var mentionIndex = SearchIndexManager.createIndex(); |
|
|
|
var mentionIndex = SearchIndexManager.createIndex(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var inlineBotsPromise = AppInlineBotsManager.getPopularBots().then(function (inlineBots) { |
|
|
|
|
|
|
|
var ids = []; |
|
|
|
|
|
|
|
angular.forEach(inlineBots, function (bot) { |
|
|
|
|
|
|
|
ids.push(bot.id); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return ids; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var chatParticipantsPromise; |
|
|
|
|
|
|
|
if (peerID < 0) { |
|
|
|
|
|
|
|
chatParticipantsPromise = AppProfileManager.getChatFull(-peerID).then(function (chatFull) { |
|
|
|
|
|
|
|
var participantsVector = (chatFull.participants || {}).participants || []; |
|
|
|
|
|
|
|
var ids = []; |
|
|
|
angular.forEach(participantsVector, function (participant) { |
|
|
|
angular.forEach(participantsVector, function (participant) { |
|
|
|
var user = AppUsersManager.getUser(participant.user_id); |
|
|
|
ids.push(participant.user_id); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return ids; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
chatParticipantsPromise = $q.when([]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$q.all({pop: inlineBotsPromise, chat: chatParticipantsPromise}).then(function (result) { |
|
|
|
|
|
|
|
var done = {}; |
|
|
|
|
|
|
|
var ids = result.pop.concat(result.chat); |
|
|
|
|
|
|
|
angular.forEach(ids, function (userID) { |
|
|
|
|
|
|
|
if (done[userID]) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
done[userID] = true; |
|
|
|
|
|
|
|
var user = AppUsersManager.getUser(userID); |
|
|
|
if (user.username) { |
|
|
|
if (user.username) { |
|
|
|
mentionUsers.push(user); |
|
|
|
mentionUsers.push(user); |
|
|
|
SearchIndexManager.indexObject(user.id, AppUsersManager.getUserSearchText(user.id), mentionIndex); |
|
|
|
SearchIndexManager.indexObject(user.id, AppUsersManager.getUserSearchText(user.id), mentionIndex); |
|
|
@ -2187,6 +2215,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
index: mentionIndex |
|
|
|
index: mentionIndex |
|
|
|
}); |
|
|
|
}); |
|
|
|
$scope.$broadcast('mentions_update'); |
|
|
|
$scope.$broadcast('mentions_update'); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|