mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-06 06:13:10 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
56b8761d6b
@ -12,7 +12,7 @@ public final class ThreadPoolTask {
|
|||||||
self.action = action
|
self.action = action
|
||||||
}
|
}
|
||||||
|
|
||||||
func execute() {
|
public func execute() {
|
||||||
if !state.cancelled.with({ $0 }) {
|
if !state.cancelled.with({ $0 }) {
|
||||||
self.action(self.state)
|
self.action(self.state)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1768,43 +1768,50 @@ public func editGroupCallTitle(account: Account, callId: Int64, accessHash: Int6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox) -> Signal<[FoundPeer], NoError> {
|
public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox, peerId: PeerId) -> Signal<[FoundPeer], NoError> {
|
||||||
return network.request(Api.functions.channels.getAdminedPublicChannels(flags: 1 << 2))
|
|
||||||
|> retryRequest
|
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
|> mapToSignal { result in
|
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||||
let chats: [Api.Chat]
|
} |> mapToSignal { inputPeer in
|
||||||
switch result {
|
guard let inputPeer = inputPeer else {
|
||||||
case let .chatsSlice(_, c):
|
return .complete()
|
||||||
chats = c
|
|
||||||
case let .chats(c):
|
|
||||||
chats = c
|
|
||||||
}
|
}
|
||||||
var subscribers: [PeerId: Int32] = [:]
|
return network.request(Api.functions.phone.getGroupCallJoinAs(peer: inputPeer))
|
||||||
let peers = chats.compactMap(parseTelegramGroupOrChannel)
|
|> retryRequest
|
||||||
for chat in chats {
|
|> mapToSignal { result in
|
||||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
var peers:[Peer]
|
||||||
switch chat {
|
switch result {
|
||||||
case let .channel(_, _, _, _, _, _, _, _, _, _, _, _, participantsCount):
|
case let .joinAsPeers(peers, chats, users):
|
||||||
if let participantsCount = participantsCount {
|
var subscribers: [PeerId: Int32] = [:]
|
||||||
subscribers[groupOrChannel.id] = participantsCount
|
let peers = chats.compactMap(parseTelegramGroupOrChannel)
|
||||||
|
for chat in chats {
|
||||||
|
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||||
|
switch chat {
|
||||||
|
case let .channel(_, _, _, _, _, _, _, _, _, _, _, _, participantsCount):
|
||||||
|
if let participantsCount = participantsCount {
|
||||||
|
subscribers[groupOrChannel.id] = participantsCount
|
||||||
|
}
|
||||||
|
case let .chat(_, _, _, _, participantsCount, _, _, _, _, _):
|
||||||
|
subscribers[groupOrChannel.id] = participantsCount
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case let .chat(_, _, _, _, participantsCount, _, _, _, _, _):
|
}
|
||||||
subscribers[groupOrChannel.id] = participantsCount
|
return postbox.transaction { transaction -> [Peer] in
|
||||||
default:
|
updatePeers(transaction: transaction, peers: peers, update: { _, updated in
|
||||||
break
|
return updated
|
||||||
|
})
|
||||||
|
return peers
|
||||||
|
} |> map { peers -> [FoundPeer] in
|
||||||
|
return peers.map { FoundPeer(peer: $0, subscribers: subscribers[$0.id]) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return postbox.transaction { transaction -> [Peer] in
|
|
||||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated in
|
|
||||||
return updated
|
|
||||||
})
|
|
||||||
return peers
|
|
||||||
} |> map { peers -> [FoundPeer] in
|
|
||||||
return peers.map { FoundPeer(peer: $0, subscribers: subscribers[$0.id]) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class CachedDisplayAsPeers: PostboxCoding {
|
public final class CachedDisplayAsPeers: PostboxCoding {
|
||||||
@ -1827,8 +1834,9 @@ public final class CachedDisplayAsPeers: PostboxCoding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func cachedGroupCallDisplayAsAvailablePeers(account: Account) -> Signal<[FoundPeer], NoError> {
|
public func cachedGroupCallDisplayAsAvailablePeers(account: Account, peerId: PeerId) -> Signal<[FoundPeer], NoError> {
|
||||||
let key = ValueBoxKey(length: 0)
|
let key = ValueBoxKey(length: 8)
|
||||||
|
key.setInt64(0, value: peerId.toInt64())
|
||||||
return account.postbox.transaction { transaction -> ([FoundPeer], Int32)? in
|
return account.postbox.transaction { transaction -> ([FoundPeer], Int32)? in
|
||||||
let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedGroupCallDisplayAsPeers, key: key)) as? CachedDisplayAsPeers
|
let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedGroupCallDisplayAsPeers, key: key)) as? CachedDisplayAsPeers
|
||||||
if let cached = cached {
|
if let cached = cached {
|
||||||
@ -1852,7 +1860,7 @@ public func cachedGroupCallDisplayAsAvailablePeers(account: Account) -> Signal<[
|
|||||||
if let (cachedPeers, timestamp) = cachedPeersAndTimestamp, currentTimestamp - timestamp < 60 * 5 {
|
if let (cachedPeers, timestamp) = cachedPeersAndTimestamp, currentTimestamp - timestamp < 60 * 5 {
|
||||||
return .single(cachedPeers)
|
return .single(cachedPeers)
|
||||||
} else {
|
} else {
|
||||||
return groupCallDisplayAsAvailablePeers(network: account.network, postbox: account.postbox)
|
return groupCallDisplayAsAvailablePeers(network: account.network, postbox: account.postbox, peerId: peerId)
|
||||||
|> mapToSignal { peers -> Signal<[FoundPeer], NoError> in
|
|> mapToSignal { peers -> Signal<[FoundPeer], NoError> in
|
||||||
return account.postbox.transaction { transaction -> [FoundPeer] in
|
return account.postbox.transaction { transaction -> [FoundPeer] in
|
||||||
let currentTimestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
let currentTimestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 18ed939bf6818139f7147cde1c34cf22eb5080a2
|
Subproject commit 2c55abafe21cf67128dc3733844e37276fbcabb3
|
||||||
Loading…
x
Reference in New Issue
Block a user