mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +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
|
||||
}
|
||||
|
||||
func execute() {
|
||||
public func execute() {
|
||||
if !state.cancelled.with({ $0 }) {
|
||||
self.action(self.state)
|
||||
}
|
||||
|
||||
@ -1768,17 +1768,20 @@ public func editGroupCallTitle(account: Account, callId: Int64, accessHash: Int6
|
||||
}
|
||||
}
|
||||
|
||||
public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox) -> Signal<[FoundPeer], NoError> {
|
||||
return network.request(Api.functions.channels.getAdminedPublicChannels(flags: 1 << 2))
|
||||
public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox, peerId: PeerId) -> Signal<[FoundPeer], NoError> {
|
||||
|
||||
return postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
} |> mapToSignal { inputPeer in
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .complete()
|
||||
}
|
||||
return network.request(Api.functions.phone.getGroupCallJoinAs(peer: inputPeer))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result in
|
||||
let chats: [Api.Chat]
|
||||
var peers:[Peer]
|
||||
switch result {
|
||||
case let .chatsSlice(_, c):
|
||||
chats = c
|
||||
case let .chats(c):
|
||||
chats = c
|
||||
}
|
||||
case let .joinAsPeers(peers, chats, users):
|
||||
var subscribers: [PeerId: Int32] = [:]
|
||||
let peers = chats.compactMap(parseTelegramGroupOrChannel)
|
||||
for chat in chats {
|
||||
@ -1795,7 +1798,6 @@ public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return postbox.transaction { transaction -> [Peer] in
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated in
|
||||
return updated
|
||||
@ -1807,6 +1809,11 @@ public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final class CachedDisplayAsPeers: PostboxCoding {
|
||||
public let peerIds: [PeerId]
|
||||
public let timestamp: Int32
|
||||
@ -1827,8 +1834,9 @@ public final class CachedDisplayAsPeers: PostboxCoding {
|
||||
}
|
||||
}
|
||||
|
||||
public func cachedGroupCallDisplayAsAvailablePeers(account: Account) -> Signal<[FoundPeer], NoError> {
|
||||
let key = ValueBoxKey(length: 0)
|
||||
public func cachedGroupCallDisplayAsAvailablePeers(account: Account, peerId: PeerId) -> Signal<[FoundPeer], NoError> {
|
||||
let key = ValueBoxKey(length: 8)
|
||||
key.setInt64(0, value: peerId.toInt64())
|
||||
return account.postbox.transaction { transaction -> ([FoundPeer], Int32)? in
|
||||
let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedGroupCallDisplayAsPeers, key: key)) as? CachedDisplayAsPeers
|
||||
if let cached = cached {
|
||||
@ -1852,7 +1860,7 @@ public func cachedGroupCallDisplayAsAvailablePeers(account: Account) -> Signal<[
|
||||
if let (cachedPeers, timestamp) = cachedPeersAndTimestamp, currentTimestamp - timestamp < 60 * 5 {
|
||||
return .single(cachedPeers)
|
||||
} 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
|
||||
return account.postbox.transaction { transaction -> [FoundPeer] in
|
||||
let currentTimestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 18ed939bf6818139f7147cde1c34cf22eb5080a2
|
||||
Subproject commit 2c55abafe21cf67128dc3733844e37276fbcabb3
|
||||
Loading…
x
Reference in New Issue
Block a user