Fixed kicks in channel

Closes #1594
This commit is contained in:
Igor Zhukov 2018-01-10 18:43:48 +04:00
parent 2a86521dae
commit 3f84e5a66f
2 changed files with 20 additions and 2 deletions

View File

@ -4034,6 +4034,12 @@ angular.module('myApp.controllers', ['myApp.i18n'])
function onChatUpdated (updates) {
ApiUpdatesManager.processUpdateMessage(updates)
$rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString})
if (updates &&
updates.updates &&
updates.updates.length &&
AppChatsManager.isChannel($scope.chatID)) {
AppProfileManager.invalidateChannelParticipants($scope.chatID)
}
}
$scope.leaveChannel = function () {
@ -4085,10 +4091,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
$scope.kickFromChannel = function (userID) {
MtpApiManager.invokeApi('channels.kickFromChannel', {
MtpApiManager.invokeApi('channels.editBanned', {
channel: AppChatsManager.getChannelInput($scope.chatID),
user_id: AppUsersManager.getUserInput(userID),
kicked: true
banned_rights: {_: 'channelBannedRights', flags: 1, until_date: 0}
}).then(onChatUpdated)
}

View File

@ -1340,6 +1340,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
})
}
function invalidateChannelParticipants(id) {
delete chatsFull[id]
delete chatFullPromises[id]
angular.forEach(chatParticipantsPromises, function (val, key) {
if (key.split('_')[0] == id) {
delete chatParticipantsPromises[key]
}
})
$rootScope.$broadcast('chat_full_update', id)
}
function getChannelPinnedMessage(id) {
return getChannelFull(id).then(function (fullChannel) {
var pinnedMessageID = fullChannel && fullChannel.pinned_msg_id
@ -1451,6 +1462,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getChatFull: getChatFull,
getChannelFull: getChannelFull,
getChannelParticipants: getChannelParticipants,
invalidateChannelParticipants: invalidateChannelParticipants,
getChannelPinnedMessage: getChannelPinnedMessage,
hideChannelPinnedMessage: hideChannelPinnedMessage
}