Browse Source

Fixed kicks in channel

Closes #1594
master
Igor Zhukov 7 years ago
parent
commit
3f84e5a66f
  1. 10
      app/js/controllers.js
  2. 12
      app/js/services.js

10
app/js/controllers.js

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

12
app/js/services.js

@ -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) { function getChannelPinnedMessage(id) {
return getChannelFull(id).then(function (fullChannel) { return getChannelFull(id).then(function (fullChannel) {
var pinnedMessageID = fullChannel && fullChannel.pinned_msg_id var pinnedMessageID = fullChannel && fullChannel.pinned_msg_id
@ -1451,6 +1462,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getChatFull: getChatFull, getChatFull: getChatFull,
getChannelFull: getChannelFull, getChannelFull: getChannelFull,
getChannelParticipants: getChannelParticipants, getChannelParticipants: getChannelParticipants,
invalidateChannelParticipants: invalidateChannelParticipants,
getChannelPinnedMessage: getChannelPinnedMessage, getChannelPinnedMessage: getChannelPinnedMessage,
hideChannelPinnedMessage: hideChannelPinnedMessage hideChannelPinnedMessage: hideChannelPinnedMessage
} }

Loading…
Cancel
Save