mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-06 06:13:10 +00:00
no message
This commit is contained in:
parent
b307f7d2d2
commit
7f96bd3f18
@ -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] = []
|
||||
|
||||
@ -64,7 +64,7 @@ public func removePeerAdmin(account: Account, peerId: PeerId, adminId: PeerId) -
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, RemovePeerAdminError> 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)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user