mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
no message
This commit is contained in:
parent
b307f7d2d2
commit
7f96bd3f18
@ -9,10 +9,22 @@ import Foundation
|
|||||||
import MtProtoKitDynamic
|
import MtProtoKitDynamic
|
||||||
#endif
|
#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
|
return account.postbox.modify { modifier -> Signal<[RenderedChannelParticipant], NoError> in
|
||||||
if let peer = modifier.getPeer(peerId), let inputChannel = apiInputChannel(peer) {
|
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
|
|> retryRequest
|
||||||
|> map { result -> [RenderedChannelParticipant] in
|
|> map { result -> [RenderedChannelParticipant] in
|
||||||
var items: [RenderedChannelParticipant] = []
|
var items: [RenderedChannelParticipant] = []
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public func removePeerAdmin(account: Account, peerId: PeerId, adminId: PeerId) -
|
|||||||
}
|
}
|
||||||
|> mapToSignal { result -> Signal<Void, RemovePeerAdminError> in
|
|> mapToSignal { result -> Signal<Void, RemovePeerAdminError> in
|
||||||
account.stateManager.addUpdates(result)
|
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
|
modifier.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||||
if let current = current as? CachedChannelData, let adminCount = current.participantsSummary.adminCount {
|
if let current = current as? CachedChannelData, let adminCount = current.participantsSummary.adminCount {
|
||||||
return current.withUpdatedParticipantsSummary(current.participantsSummary.withUpdatedAdminCount(max(1, adminCount - 1)))
|
return current.withUpdatedParticipantsSummary(current.participantsSummary.withUpdatedAdminCount(max(1, adminCount - 1)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user