mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
0f081f9ac3
1
BUCK
1
BUCK
@ -466,6 +466,7 @@ apple_binary(
|
||||
linker_flags = [
|
||||
"-e",
|
||||
"_WKExtensionMain",
|
||||
"-lWKExtensionMainLegacy",
|
||||
],
|
||||
configs = watch_extension_binary_configs(),
|
||||
frameworks = [
|
||||
|
@ -4814,7 +4814,7 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"Wallet.Receive.CopyInvoiceUrl" = "Copy Invoice URL";
|
||||
"Wallet.Receive.ShareAddress" = "Share Wallet Address";
|
||||
"Wallet.Receive.ShareInvoiceUrl" = "Share Invoice URL";
|
||||
"Wallet.Receive.ShareUrlInfo" = "Share this link with other Gram wallet owners to receive Grams from them.";
|
||||
"Wallet.Receive.ShareUrlInfo" = "Share this link with other Gram wallet owners to receive Grams from them. Note: this link won't work for real Grams.";
|
||||
"Wallet.Receive.AmountHeader" = "AMOUNT";
|
||||
"Wallet.Receive.AmountText" = "Grams to receive";
|
||||
"Wallet.Receive.AmountInfo" = "You can specify the amount and purpose of the payment to save the sender some time.";
|
||||
|
@ -26,7 +26,7 @@ brew install cmake ant
|
||||
|
||||
```
|
||||
mkdir -p $HOME/buck_source
|
||||
cd tools/buck
|
||||
cd tools/buck-build
|
||||
sh ./prepare_buck_source.sh $HOME/buck_source
|
||||
```
|
||||
|
||||
|
@ -651,7 +651,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
print("Starting with \(documentsPath)")
|
||||
#endif
|
||||
|
||||
let storage = WalletStorageInterfaceImpl(path: documentsPath + "/data", configurationPath: documentsPath + "/configuration")
|
||||
let storage = WalletStorageInterfaceImpl(path: documentsPath + "/data", configurationPath: documentsPath + "/configuration_v2")
|
||||
|
||||
let initialConfigValue = storage.mergedLocalWalletConfiguration()
|
||||
|> take(1)
|
||||
@ -828,6 +828,6 @@ struct MergedLocalWalletConfiguration: Codable, Equatable {
|
||||
|
||||
private extension MergedLocalWalletConfiguration {
|
||||
static var `default`: MergedLocalWalletConfiguration {
|
||||
return MergedLocalWalletConfiguration(configuration: LocalWalletConfiguration(source: .url("https://test.ton.org/config.json"), blockchainName: "testnet"), resolved: nil)
|
||||
return MergedLocalWalletConfiguration(configuration: LocalWalletConfiguration(source: .url("https://test.ton.org/config.json"), blockchainName: "testnet2"), resolved: nil)
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
"Wallet.Receive.CopyInvoiceUrl" = "Copy Invoice URL";
|
||||
"Wallet.Receive.ShareAddress" = "Share Wallet Address";
|
||||
"Wallet.Receive.ShareInvoiceUrl" = "Share Invoice URL";
|
||||
"Wallet.Receive.ShareUrlInfo" = "Share this link with other Gram wallet owners to receive Grams from them.";
|
||||
"Wallet.Receive.ShareUrlInfo" = "Share this link with other Gram wallet owners to receive Grams from them. Note: this link won't work for real Grams.";
|
||||
"Wallet.Receive.AmountHeader" = "AMOUNT";
|
||||
"Wallet.Receive.AmountText" = "Grams to receive";
|
||||
"Wallet.Receive.AmountInfo" = "You can specify the amount and purpose of the payment to save the sender some time.";
|
||||
|
@ -772,9 +772,22 @@ public final class AccountViewTracker {
|
||||
self.cachedDataContexts[peerId] = context
|
||||
}
|
||||
context.timestamp = CFAbsoluteTimeGetCurrent()
|
||||
if let account = self.account {
|
||||
context.disposable.set(combineLatest(fetchAndUpdateSupplementalCachedPeerData(peerId: peerId, network: account.network, postbox: account.postbox), fetchAndUpdateCachedPeerData(accountPeerId: account.peerId, peerId: peerId, network: account.network, postbox: account.postbox)).start())
|
||||
guard let account = self.account else {
|
||||
return
|
||||
}
|
||||
let queue = self.queue
|
||||
context.disposable.set(combineLatest(fetchAndUpdateSupplementalCachedPeerData(peerId: peerId, network: account.network, postbox: account.postbox), fetchAndUpdateCachedPeerData(accountPeerId: account.peerId, peerId: peerId, network: account.network, postbox: account.postbox)).start(next: { [weak self] supplementalStatus, cachedStatus in
|
||||
queue.async {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if !supplementalStatus || !cachedStatus {
|
||||
if let existingContext = strongSelf.cachedDataContexts[peerId] {
|
||||
existingContext.timestamp = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -801,9 +814,22 @@ public final class AccountViewTracker {
|
||||
context.viewIds.insert(viewId)
|
||||
|
||||
if dataUpdated {
|
||||
if let account = self.account {
|
||||
context.disposable.set(combineLatest(fetchAndUpdateSupplementalCachedPeerData(peerId: peerId, network: account.network, postbox: account.postbox), fetchAndUpdateCachedPeerData(accountPeerId: account.peerId, peerId: peerId, network: account.network, postbox: account.postbox)).start())
|
||||
guard let account = self.account else {
|
||||
return
|
||||
}
|
||||
let queue = self.queue
|
||||
context.disposable.set(combineLatest(fetchAndUpdateSupplementalCachedPeerData(peerId: peerId, network: account.network, postbox: account.postbox), fetchAndUpdateCachedPeerData(accountPeerId: account.peerId, peerId: peerId, network: account.network, postbox: account.postbox)).start(next: { [weak self] supplementalStatus, cachedStatus in
|
||||
queue.async {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if !supplementalStatus || !cachedStatus {
|
||||
if let existingContext = strongSelf.cachedDataContexts[peerId] {
|
||||
existingContext.timestamp = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,149 +2,176 @@ import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
import SwiftSignalKit
|
||||
|
||||
import SyncCore
|
||||
|
||||
func fetchAndUpdateSupplementalCachedPeerData(peerId rawPeerId: PeerId, network: Network, postbox: Postbox) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
guard let rawPeer = transaction.getPeer(rawPeerId) else {
|
||||
func fetchAndUpdateSupplementalCachedPeerData(peerId rawPeerId: PeerId, network: Network, postbox: Postbox) -> Signal<Bool, NoError> {
|
||||
return postbox.combinedView(keys: [.basicPeer(rawPeerId)])
|
||||
|> mapToSignal { views -> Signal<Peer, NoError> in
|
||||
guard let view = views.views[.basicPeer(rawPeerId)] as? BasicPeerView else {
|
||||
return .complete()
|
||||
}
|
||||
|
||||
let peer: Peer
|
||||
if let secretChat = rawPeer as? TelegramSecretChat {
|
||||
guard let user = transaction.getPeer(secretChat.regularPeerId) else {
|
||||
return .complete()
|
||||
}
|
||||
peer = user
|
||||
} else {
|
||||
peer = rawPeer
|
||||
guard let peer = view.peer else {
|
||||
return .complete()
|
||||
}
|
||||
return .single(peer)
|
||||
}
|
||||
|> take(1)
|
||||
|> mapToSignal { _ -> Signal<Bool, NoError> in
|
||||
return postbox.transaction { transaction -> Signal<Bool, NoError> in
|
||||
guard let rawPeer = transaction.getPeer(rawPeerId) else {
|
||||
return .single(false)
|
||||
}
|
||||
|
||||
let cachedData = transaction.getPeerCachedData(peerId: peer.id)
|
||||
|
||||
if let cachedData = cachedData as? CachedUserData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
let peer: Peer
|
||||
if let secretChat = rawPeer as? TelegramSecretChat {
|
||||
guard let user = transaction.getPeer(secretChat.regularPeerId) else {
|
||||
return .single(false)
|
||||
}
|
||||
peer = user
|
||||
} else {
|
||||
peer = rawPeer
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedGroupData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
|
||||
let cachedData = transaction.getPeerCachedData(peerId: peer.id)
|
||||
|
||||
if let cachedData = cachedData as? CachedUserData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .single(true)
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedGroupData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .single(true)
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedChannelData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .single(true)
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedSecretChatData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .single(true)
|
||||
}
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedChannelData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
} else if let cachedData = cachedData as? CachedSecretChatData {
|
||||
if cachedData.peerStatusSettings != nil {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
if peer.id.namespace == Namespaces.Peer.SecretChat {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
var peerStatusSettings: PeerStatusSettings
|
||||
if let peer = transaction.getPeer(peer.id), let associatedPeerId = peer.associatedPeerId, !transaction.isPeerContact(peerId: associatedPeerId) {
|
||||
if let peer = peer as? TelegramSecretChat, case .creator = peer.role {
|
||||
|
||||
if peer.id.namespace == Namespaces.Peer.SecretChat {
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
var peerStatusSettings: PeerStatusSettings
|
||||
if let peer = transaction.getPeer(peer.id), let associatedPeerId = peer.associatedPeerId, !transaction.isPeerContact(peerId: associatedPeerId) {
|
||||
if let peer = peer as? TelegramSecretChat, case .creator = peer.role {
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings = []
|
||||
} else {
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings.insert(.canReport)
|
||||
}
|
||||
} else {
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings = []
|
||||
} else {
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings.insert(.canReport)
|
||||
}
|
||||
} else {
|
||||
peerStatusSettings = PeerStatusSettings()
|
||||
peerStatusSettings = []
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peer.id], update: { peerId, current in
|
||||
if let current = current as? CachedSecretChatData {
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return CachedSecretChatData(peerStatusSettings: peerStatusSettings)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if let inputPeer = apiInputPeer(peer) {
|
||||
return network.request(Api.functions.messages.getPeerSettings(peer: inputPeer))
|
||||
|> retryRequest
|
||||
|> mapToSignal { peerSettings -> Signal<Void, NoError> in
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: peerSettings)
|
||||
|
||||
return postbox.transaction { transaction -> Void in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peer.id]), update: { _, current in
|
||||
switch peer.id.namespace {
|
||||
case Namespaces.Peer.CloudUser:
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudGroup:
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudChannel:
|
||||
let previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
default:
|
||||
break
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peer.id], update: { peerId, current in
|
||||
if let current = current as? CachedSecretChatData {
|
||||
return current.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
} else {
|
||||
return CachedSecretChatData(peerStatusSettings: peerStatusSettings)
|
||||
}
|
||||
return current
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
} else if let inputPeer = apiInputPeer(peer) {
|
||||
return network.request(Api.functions.messages.getPeerSettings(peer: inputPeer))
|
||||
|> retryRequest
|
||||
|> mapToSignal { peerSettings -> Signal<Bool, NoError> in
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: peerSettings)
|
||||
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peer.id]), update: { _, current in
|
||||
switch peer.id.namespace {
|
||||
case Namespaces.Peer.CloudUser:
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudGroup:
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
case Namespaces.Peer.CloudChannel:
|
||||
let previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
return previous.withUpdatedPeerStatusSettings(peerStatusSettings)
|
||||
default:
|
||||
break
|
||||
}
|
||||
return current
|
||||
})
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single(false)
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
|> switchToLatest
|
||||
}
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerId, network: Network, postbox: Postbox) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> (Api.InputUser?, Peer?, PeerId) in
|
||||
guard let rawPeer = transaction.getPeer(rawPeerId) else {
|
||||
func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerId, network: Network, postbox: Postbox) -> Signal<Bool, NoError> {
|
||||
return postbox.combinedView(keys: [.basicPeer(rawPeerId)])
|
||||
|> mapToSignal { views -> Signal<Peer, NoError> in
|
||||
guard let view = views.views[.basicPeer(rawPeerId)] as? BasicPeerView else {
|
||||
return .complete()
|
||||
}
|
||||
guard let peer = view.peer else {
|
||||
return .complete()
|
||||
}
|
||||
return .single(peer)
|
||||
}
|
||||
|> take(1)
|
||||
|> mapToSignal { _ -> Signal<Bool, NoError> in
|
||||
return postbox.transaction { transaction -> (Api.InputUser?, Peer?, PeerId) in
|
||||
guard let rawPeer = transaction.getPeer(rawPeerId) else {
|
||||
if rawPeerId == accountPeerId {
|
||||
return (.inputUserSelf, transaction.getPeer(rawPeerId), rawPeerId)
|
||||
} else {
|
||||
return (nil, nil, rawPeerId)
|
||||
}
|
||||
}
|
||||
|
||||
let peer: Peer
|
||||
if let secretChat = rawPeer as? TelegramSecretChat {
|
||||
guard let user = transaction.getPeer(secretChat.regularPeerId) else {
|
||||
return (nil, nil, rawPeerId)
|
||||
}
|
||||
peer = user
|
||||
} else {
|
||||
peer = rawPeer
|
||||
}
|
||||
|
||||
if rawPeerId == accountPeerId {
|
||||
return (.inputUserSelf, transaction.getPeer(rawPeerId), rawPeerId)
|
||||
} else {
|
||||
return (nil, nil, rawPeerId)
|
||||
return (apiInputUser(peer), peer, peer.id)
|
||||
}
|
||||
}
|
||||
|
||||
let peer: Peer
|
||||
if let secretChat = rawPeer as? TelegramSecretChat {
|
||||
guard let user = transaction.getPeer(secretChat.regularPeerId) else {
|
||||
return (nil, nil, rawPeerId)
|
||||
}
|
||||
peer = user
|
||||
} else {
|
||||
peer = rawPeer
|
||||
}
|
||||
|
||||
if rawPeerId == accountPeerId {
|
||||
return (.inputUserSelf, transaction.getPeer(rawPeerId), rawPeerId)
|
||||
} else {
|
||||
return (apiInputUser(peer), peer, peer.id)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { inputUser, maybePeer, peerId -> Signal<Void, NoError> in
|
||||
if let inputUser = inputUser {
|
||||
return network.request(Api.functions.users.getFullUser(id: inputUser))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
switch result {
|
||||
|> mapToSignal { inputUser, maybePeer, peerId -> Signal<Bool, NoError> in
|
||||
if let inputUser = inputUser {
|
||||
return network.request(Api.functions.users.getFullUser(id: inputUser))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Bool, NoError> in
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
switch result {
|
||||
case let .userFull(userFull):
|
||||
let telegramUser = TelegramUser(user: userFull.user)
|
||||
updatePeers(transaction: transaction, peers: [telegramUser], update: { _, updated -> Peer in
|
||||
@ -154,296 +181,300 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI
|
||||
if let presence = TelegramUserPresence(apiUser: userFull.user) {
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: [telegramUser.id: presence])
|
||||
}
|
||||
}
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
switch result {
|
||||
case let .userFull(userFull):
|
||||
let botInfo = userFull.botInfo.flatMap(BotInfo.init(apiBotInfo:))
|
||||
let isBlocked = (userFull.flags & (1 << 0)) != 0
|
||||
let callsAvailable = (userFull.flags & (1 << 4)) != 0
|
||||
let callsPrivate = (userFull.flags & (1 << 5)) != 0
|
||||
let canPinMessages = (userFull.flags & (1 << 7)) != 0
|
||||
let pinnedMessageId = userFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: userFull.settings)
|
||||
|
||||
var hasScheduledMessages = false
|
||||
if (userFull.flags & 1 << 12) != 0 {
|
||||
hasScheduledMessages = true
|
||||
}
|
||||
|
||||
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerStatusSettings(peerStatusSettings).withUpdatedPinnedMessageId(pinnedMessageId).withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
return network.request(Api.functions.messages.getFullChat(chatId: peerId.id))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
switch fullChat {
|
||||
case let .chatFull(chatFull):
|
||||
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: chatFull.notifySettings)])
|
||||
case .channelFull:
|
||||
break
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
||||
let previous: CachedUserData
|
||||
if let current = current as? CachedUserData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedUserData()
|
||||
}
|
||||
|
||||
switch fullChat {
|
||||
case let .chatFull(chatFull):
|
||||
var botInfos: [CachedPeerBotInfo] = []
|
||||
for botInfo in chatFull.botInfo ?? [] {
|
||||
switch botInfo {
|
||||
case let .botInfo(userId, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
|
||||
botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo))
|
||||
}
|
||||
}
|
||||
let participants = CachedGroupParticipants(apiParticipants: chatFull.participants)
|
||||
let exportedInvitation = ExportedInvitation(apiExportedInvite: chatFull.exportedInvite)
|
||||
let pinnedMessageId = chatFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
if let presence = TelegramUserPresence(apiUser: user) {
|
||||
peerPresences[telegramUser.id] = presence
|
||||
}
|
||||
}
|
||||
switch result {
|
||||
case let .userFull(userFull):
|
||||
let botInfo = userFull.botInfo.flatMap(BotInfo.init(apiBotInfo:))
|
||||
let isBlocked = (userFull.flags & (1 << 0)) != 0
|
||||
let callsAvailable = (userFull.flags & (1 << 4)) != 0
|
||||
let callsPrivate = (userFull.flags & (1 << 5)) != 0
|
||||
let canPinMessages = (userFull.flags & (1 << 7)) != 0
|
||||
let pinnedMessageId = userFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
var flags = CachedGroupFlags()
|
||||
if (chatFull.flags & 1 << 7) != 0 {
|
||||
flags.insert(.canChangeUsername)
|
||||
}
|
||||
let peerStatusSettings = PeerStatusSettings(apiSettings: userFull.settings)
|
||||
|
||||
var hasScheduledMessages = false
|
||||
if (chatFull.flags & 1 << 8) != 0 {
|
||||
if (userFull.flags & 1 << 12) != 0 {
|
||||
hasScheduledMessages = true
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
|
||||
return previous.withUpdatedParticipants(participants)
|
||||
.withUpdatedExportedInvitation(exportedInvitation)
|
||||
.withUpdatedBotInfos(botInfos)
|
||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
.withUpdatedAbout(chatFull.about)
|
||||
.withUpdatedFlags(flags)
|
||||
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
})
|
||||
case .channelFull:
|
||||
break
|
||||
|
||||
return previous.withUpdatedAbout(userFull.about).withUpdatedBotInfo(botInfo).withUpdatedCommonGroupCount(userFull.commonChatsCount).withUpdatedIsBlocked(isBlocked).withUpdatedCallsAvailable(callsAvailable).withUpdatedCallsPrivate(callsPrivate).withUpdatedCanPinMessages(canPinMessages).withUpdatedPeerStatusSettings(peerStatusSettings).withUpdatedPinnedMessageId(pinnedMessageId).withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
}
|
||||
})
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let inputChannel = maybePeer.flatMap(apiInputChannel) {
|
||||
return network.request(Api.functions.channels.getFullChannel(channel: inputChannel))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<Api.messages.ChatFull?, NoError> in
|
||||
if error.errorDescription == "CHANNEL_PRIVATE" {
|
||||
return .single(nil)
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
if let result = result {
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
return network.request(Api.functions.messages.getFullChat(chatId: peerId.id))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Bool, NoError> in
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
switch fullChat {
|
||||
case let .channelFull(channelFull):
|
||||
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: channelFull.notifySettings)])
|
||||
case .chatFull:
|
||||
break
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
switch fullChat {
|
||||
case let .chatFull(chatFull):
|
||||
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: chatFull.notifySettings)])
|
||||
case .channelFull:
|
||||
break
|
||||
}
|
||||
|
||||
switch fullChat {
|
||||
case let .chatFull(chatFull):
|
||||
var botInfos: [CachedPeerBotInfo] = []
|
||||
for botInfo in chatFull.botInfo ?? [] {
|
||||
switch botInfo {
|
||||
case let .botInfo(userId, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
|
||||
botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo))
|
||||
}
|
||||
}
|
||||
let participants = CachedGroupParticipants(apiParticipants: chatFull.participants)
|
||||
let exportedInvitation = ExportedInvitation(apiExportedInvite: chatFull.exportedInvite)
|
||||
let pinnedMessageId = chatFull.pinnedMsgId.flatMap({ MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: $0) })
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
if let presence = TelegramUserPresence(apiUser: user) {
|
||||
peerPresences[telegramUser.id] = presence
|
||||
}
|
||||
}
|
||||
|
||||
switch fullChat {
|
||||
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, folderId, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, pts):
|
||||
var channelFlags = CachedChannelFlags()
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
channelFlags.insert(.canDisplayParticipants)
|
||||
}
|
||||
if (flags & (1 << 6)) != 0 {
|
||||
channelFlags.insert(.canChangeUsername)
|
||||
}
|
||||
if (flags & (1 << 10)) == 0 {
|
||||
channelFlags.insert(.preHistoryEnabled)
|
||||
}
|
||||
if (flags & (1 << 12)) != 0 {
|
||||
channelFlags.insert(.canViewStats)
|
||||
}
|
||||
if (flags & (1 << 7)) != 0 {
|
||||
channelFlags.insert(.canSetStickerSet)
|
||||
}
|
||||
if (flags & (1 << 16)) != 0 {
|
||||
channelFlags.insert(.canChangePeerGeoLocation)
|
||||
}
|
||||
|
||||
let linkedDiscussionPeerId: PeerId?
|
||||
if let linkedChatId = linkedChatId, linkedChatId != 0 {
|
||||
linkedDiscussionPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: linkedChatId)
|
||||
} else {
|
||||
linkedDiscussionPeerId = nil
|
||||
}
|
||||
|
||||
let peerGeoLocation: PeerGeoLocation?
|
||||
if let location = location {
|
||||
peerGeoLocation = PeerGeoLocation(apiLocation: location)
|
||||
} else {
|
||||
peerGeoLocation = nil
|
||||
}
|
||||
|
||||
var botInfos: [CachedPeerBotInfo] = []
|
||||
for botInfo in apiBotInfos {
|
||||
switch botInfo {
|
||||
case let .botInfo(userId, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
|
||||
botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo))
|
||||
}
|
||||
}
|
||||
|
||||
var pinnedMessageId: MessageId?
|
||||
if let pinnedMsgId = pinnedMsgId {
|
||||
pinnedMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: pinnedMsgId)
|
||||
}
|
||||
|
||||
var minAvailableMessageId: MessageId?
|
||||
if let minAvailableMsgId = minAvailableMsgId {
|
||||
minAvailableMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: minAvailableMsgId)
|
||||
|
||||
if let pinnedMsgId = pinnedMsgId, pinnedMsgId < minAvailableMsgId {
|
||||
pinnedMessageId = nil
|
||||
}
|
||||
}
|
||||
|
||||
var migrationReference: ChannelMigrationReference?
|
||||
if let migratedFromChatId = migratedFromChatId, let migratedFromMaxId = migratedFromMaxId {
|
||||
migrationReference = ChannelMigrationReference(maxMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: migratedFromChatId), namespace: Namespaces.Message.Cloud, id: migratedFromMaxId))
|
||||
}
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
if let presence = TelegramUserPresence(apiUser: user) {
|
||||
peerPresences[telegramUser.id] = presence
|
||||
}
|
||||
}
|
||||
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in
|
||||
let namespace: ItemCollectionId.Namespace
|
||||
switch apiSet {
|
||||
case let .stickerSet(flags, _, _, _, _, _, _, _, _, _):
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
namespace = Namespaces.ItemCollection.CloudMaskPacks
|
||||
} else {
|
||||
namespace = Namespaces.ItemCollection.CloudStickerPacks
|
||||
}
|
||||
}
|
||||
|
||||
return StickerPackCollectionInfo(apiSet: apiSet, namespace: namespace)
|
||||
}
|
||||
|
||||
var hasScheduledMessages = false
|
||||
if (flags & (1 << 19)) != 0 {
|
||||
hasScheduledMessages = true
|
||||
}
|
||||
|
||||
var minAvailableMessageIdUpdated = false
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||
var previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
|
||||
previous = previous.withUpdatedIsNotAccessible(false)
|
||||
|
||||
minAvailableMessageIdUpdated = previous.minAvailableMessageId != minAvailableMessageId
|
||||
|
||||
return previous.withUpdatedFlags(channelFlags)
|
||||
.withUpdatedAbout(about)
|
||||
.withUpdatedParticipantsSummary(CachedChannelParticipantsSummary(memberCount: participantsCount, adminCount: adminsCount, bannedCount: bannedCount, kickedCount: kickedCount))
|
||||
.withUpdatedExportedInvitation(ExportedInvitation(apiExportedInvite: apiExportedInvite))
|
||||
.withUpdatedBotInfos(botInfos)
|
||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
.withUpdatedStickerPack(stickerPack)
|
||||
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
||||
.withUpdatedMigrationReference(migrationReference)
|
||||
.withUpdatedLinkedDiscussionPeerId(linkedDiscussionPeerId)
|
||||
.withUpdatedPeerGeoLocation(peerGeoLocation)
|
||||
.withUpdatedSlowModeTimeout(slowmodeSeconds)
|
||||
.withUpdatedSlowModeValidUntilTimestamp(slowmodeNextSendDate)
|
||||
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
})
|
||||
|
||||
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
||||
var resourceIds: [WrappedMediaResourceId] = []
|
||||
transaction.deleteMessagesInRange(peerId: peerId, namespace: minAvailableMessageId.namespace, minId: 1, maxId: minAvailableMessageId.id, forEachMedia: { media in
|
||||
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
||||
})
|
||||
if !resourceIds.isEmpty {
|
||||
let _ = postbox.mediaBox.removeCachedResources(Set(resourceIds)).start()
|
||||
}
|
||||
}
|
||||
case .chatFull:
|
||||
break
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
var flags = CachedGroupFlags()
|
||||
if (chatFull.flags & 1 << 7) != 0 {
|
||||
flags.insert(.canChangeUsername)
|
||||
}
|
||||
|
||||
var hasScheduledMessages = false
|
||||
if (chatFull.flags & 1 << 8) != 0 {
|
||||
hasScheduledMessages = true
|
||||
}
|
||||
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||
let previous: CachedGroupData
|
||||
if let current = current as? CachedGroupData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedGroupData()
|
||||
}
|
||||
|
||||
return previous.withUpdatedParticipants(participants)
|
||||
.withUpdatedExportedInvitation(exportedInvitation)
|
||||
.withUpdatedBotInfos(botInfos)
|
||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
.withUpdatedAbout(chatFull.about)
|
||||
.withUpdatedFlags(flags)
|
||||
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
})
|
||||
case .channelFull:
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, _ in
|
||||
var updated = CachedChannelData()
|
||||
updated = updated.withUpdatedIsNotAccessible(true)
|
||||
return updated
|
||||
})
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else if let inputChannel = maybePeer.flatMap(apiInputChannel) {
|
||||
return network.request(Api.functions.channels.getFullChannel(channel: inputChannel))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<Api.messages.ChatFull?, NoError> in
|
||||
if error.errorDescription == "CHANNEL_PRIVATE" {
|
||||
return .single(nil)
|
||||
}
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Bool, NoError> in
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
if let result = result {
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
switch fullChat {
|
||||
case let .channelFull(channelFull):
|
||||
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: channelFull.notifySettings)])
|
||||
case .chatFull:
|
||||
break
|
||||
}
|
||||
|
||||
switch fullChat {
|
||||
case let .channelFull(flags, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, _, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, folderId, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, pts):
|
||||
var channelFlags = CachedChannelFlags()
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
channelFlags.insert(.canDisplayParticipants)
|
||||
}
|
||||
if (flags & (1 << 6)) != 0 {
|
||||
channelFlags.insert(.canChangeUsername)
|
||||
}
|
||||
if (flags & (1 << 10)) == 0 {
|
||||
channelFlags.insert(.preHistoryEnabled)
|
||||
}
|
||||
if (flags & (1 << 12)) != 0 {
|
||||
channelFlags.insert(.canViewStats)
|
||||
}
|
||||
if (flags & (1 << 7)) != 0 {
|
||||
channelFlags.insert(.canSetStickerSet)
|
||||
}
|
||||
if (flags & (1 << 16)) != 0 {
|
||||
channelFlags.insert(.canChangePeerGeoLocation)
|
||||
}
|
||||
|
||||
let linkedDiscussionPeerId: PeerId?
|
||||
if let linkedChatId = linkedChatId, linkedChatId != 0 {
|
||||
linkedDiscussionPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: linkedChatId)
|
||||
} else {
|
||||
linkedDiscussionPeerId = nil
|
||||
}
|
||||
|
||||
let peerGeoLocation: PeerGeoLocation?
|
||||
if let location = location {
|
||||
peerGeoLocation = PeerGeoLocation(apiLocation: location)
|
||||
} else {
|
||||
peerGeoLocation = nil
|
||||
}
|
||||
|
||||
var botInfos: [CachedPeerBotInfo] = []
|
||||
for botInfo in apiBotInfos {
|
||||
switch botInfo {
|
||||
case let .botInfo(userId, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
|
||||
botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo))
|
||||
}
|
||||
}
|
||||
|
||||
var pinnedMessageId: MessageId?
|
||||
if let pinnedMsgId = pinnedMsgId {
|
||||
pinnedMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: pinnedMsgId)
|
||||
}
|
||||
|
||||
var minAvailableMessageId: MessageId?
|
||||
if let minAvailableMsgId = minAvailableMsgId {
|
||||
minAvailableMessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: minAvailableMsgId)
|
||||
|
||||
if let pinnedMsgId = pinnedMsgId, pinnedMsgId < minAvailableMsgId {
|
||||
pinnedMessageId = nil
|
||||
}
|
||||
}
|
||||
|
||||
var migrationReference: ChannelMigrationReference?
|
||||
if let migratedFromChatId = migratedFromChatId, let migratedFromMaxId = migratedFromMaxId {
|
||||
migrationReference = ChannelMigrationReference(maxMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: migratedFromChatId), namespace: Namespaces.Message.Cloud, id: migratedFromMaxId))
|
||||
}
|
||||
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: PeerPresence] = [:]
|
||||
for chat in chats {
|
||||
if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) {
|
||||
peers.append(groupOrChannel)
|
||||
}
|
||||
}
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
if let presence = TelegramUserPresence(apiUser: user) {
|
||||
peerPresences[telegramUser.id] = presence
|
||||
}
|
||||
}
|
||||
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in
|
||||
let namespace: ItemCollectionId.Namespace
|
||||
switch apiSet {
|
||||
case let .stickerSet(flags, _, _, _, _, _, _, _, _, _):
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
namespace = Namespaces.ItemCollection.CloudMaskPacks
|
||||
} else {
|
||||
namespace = Namespaces.ItemCollection.CloudStickerPacks
|
||||
}
|
||||
}
|
||||
|
||||
return StickerPackCollectionInfo(apiSet: apiSet, namespace: namespace)
|
||||
}
|
||||
|
||||
var hasScheduledMessages = false
|
||||
if (flags & (1 << 19)) != 0 {
|
||||
hasScheduledMessages = true
|
||||
}
|
||||
|
||||
var minAvailableMessageIdUpdated = false
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current in
|
||||
var previous: CachedChannelData
|
||||
if let current = current as? CachedChannelData {
|
||||
previous = current
|
||||
} else {
|
||||
previous = CachedChannelData()
|
||||
}
|
||||
|
||||
previous = previous.withUpdatedIsNotAccessible(false)
|
||||
|
||||
minAvailableMessageIdUpdated = previous.minAvailableMessageId != minAvailableMessageId
|
||||
|
||||
return previous.withUpdatedFlags(channelFlags)
|
||||
.withUpdatedAbout(about)
|
||||
.withUpdatedParticipantsSummary(CachedChannelParticipantsSummary(memberCount: participantsCount, adminCount: adminsCount, bannedCount: bannedCount, kickedCount: kickedCount))
|
||||
.withUpdatedExportedInvitation(ExportedInvitation(apiExportedInvite: apiExportedInvite))
|
||||
.withUpdatedBotInfos(botInfos)
|
||||
.withUpdatedPinnedMessageId(pinnedMessageId)
|
||||
.withUpdatedStickerPack(stickerPack)
|
||||
.withUpdatedMinAvailableMessageId(minAvailableMessageId)
|
||||
.withUpdatedMigrationReference(migrationReference)
|
||||
.withUpdatedLinkedDiscussionPeerId(linkedDiscussionPeerId)
|
||||
.withUpdatedPeerGeoLocation(peerGeoLocation)
|
||||
.withUpdatedSlowModeTimeout(slowmodeSeconds)
|
||||
.withUpdatedSlowModeValidUntilTimestamp(slowmodeNextSendDate)
|
||||
.withUpdatedHasScheduledMessages(hasScheduledMessages)
|
||||
})
|
||||
|
||||
if let minAvailableMessageId = minAvailableMessageId, minAvailableMessageIdUpdated {
|
||||
var resourceIds: [WrappedMediaResourceId] = []
|
||||
transaction.deleteMessagesInRange(peerId: peerId, namespace: minAvailableMessageId.namespace, minId: 1, maxId: minAvailableMessageId.id, forEachMedia: { media in
|
||||
addMessageMediaResourceIdsToRemove(media: media, resourceIds: &resourceIds)
|
||||
})
|
||||
if !resourceIds.isEmpty {
|
||||
let _ = postbox.mediaBox.removeCachedResources(Set(resourceIds)).start()
|
||||
}
|
||||
}
|
||||
case .chatFull:
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { _, _ in
|
||||
var updated = CachedChannelData()
|
||||
updated = updated.withUpdatedIsNotAccessible(true)
|
||||
return updated
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single(false)
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -448,12 +448,12 @@ public final class WalletStrings: Equatable {
|
||||
public var Wallet_SecureStorageReset_Title: String { return self._s[218]! }
|
||||
public var Wallet_Receive_CommentHeader: String { return self._s[219]! }
|
||||
public var Wallet_Info_ReceiveGrams: String { return self._s[220]! }
|
||||
public func Wallet_Updated_MinutesAgo(_ value: Int32) -> String {
|
||||
public func Wallet_Updated_HoursAgo(_ value: Int32) -> String {
|
||||
let form = getPluralizationForm(self.lc, value)
|
||||
let stringValue = walletStringsFormattedNumber(value, self.groupingSeparator)
|
||||
return String(format: self._ps[0 * 6 + Int(form.rawValue)]!, stringValue)
|
||||
}
|
||||
public func Wallet_Updated_HoursAgo(_ value: Int32) -> String {
|
||||
public func Wallet_Updated_MinutesAgo(_ value: Int32) -> String {
|
||||
let form = getPluralizationForm(self.lc, value)
|
||||
let stringValue = walletStringsFormattedNumber(value, self.groupingSeparator)
|
||||
return String(format: self._ps[1 * 6 + Int(form.rawValue)]!, stringValue)
|
||||
|
Loading…
x
Reference in New Issue
Block a user