diff --git a/TelegramCore/ChannelMembers.swift b/TelegramCore/ChannelMembers.swift index e4b8dbd7f6..00c4866345 100644 --- a/TelegramCore/ChannelMembers.swift +++ b/TelegramCore/ChannelMembers.swift @@ -9,10 +9,22 @@ import Foundation import MtProtoKitDynamic #endif -public func channelMembers(account: Account, peerId: PeerId) -> Signal<[RenderedChannelParticipant], NoError> { +public enum ChannelMembersFilter { + case none + case search(String) +} + +public func channelMembers(account: Account, peerId: PeerId, filter: ChannelMembersFilter = .none) -> Signal<[RenderedChannelParticipant], NoError> { return account.postbox.modify { modifier -> Signal<[RenderedChannelParticipant], NoError> in if let peer = modifier.getPeer(peerId), let inputChannel = apiInputChannel(peer) { - return account.network.request(Api.functions.channels.getParticipants(channel: inputChannel, filter: .channelParticipantsRecent, offset: 0, limit: 100)) + let apiFilter: Api.ChannelParticipantsFilter + switch filter { + case .none: + apiFilter = .channelParticipantsRecent + case let .search(query): + apiFilter = .channelParticipantsSearch(q: query) + } + return account.network.request(Api.functions.channels.getParticipants(channel: inputChannel, filter: apiFilter, offset: 0, limit: 100)) |> retryRequest |> map { result -> [RenderedChannelParticipant] in var items: [RenderedChannelParticipant] = [] diff --git a/TelegramCore/PeerAdmins.swift b/TelegramCore/PeerAdmins.swift index 01c69b5a3e..3092aeb3fa 100644 --- a/TelegramCore/PeerAdmins.swift +++ b/TelegramCore/PeerAdmins.swift @@ -64,7 +64,7 @@ public func removePeerAdmin(account: Account, peerId: PeerId, adminId: PeerId) - } |> mapToSignal { result -> Signal in account.stateManager.addUpdates(result) - return account.postbox.modify { moifier -> Void in + return account.postbox.modify { modifier -> Void in modifier.updatePeerCachedData(peerIds: [peerId], update: { _, current in if let current = current as? CachedChannelData, let adminCount = current.participantsSummary.adminCount { return current.withUpdatedParticipantsSummary(current.participantsSummary.withUpdatedAdminCount(max(1, adminCount - 1)))