mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 16:06:59 +00:00
Update API [skip ci]
This commit is contained in:
parent
71f367027d
commit
96579d1c80
@ -23,6 +23,7 @@ struct ParsedDialogs {
|
||||
let topMessageIds: [PeerId: MessageId]
|
||||
let storeMessages: [StoreMessage]
|
||||
let ttlPeriods: [PeerId: CachedPeerAutoremoveTimeout]
|
||||
let hiddenTranslations: [PeerId: Bool]
|
||||
|
||||
let lowerNonPinnedIndex: MessageIndex?
|
||||
let referencedFolders: [PeerGroupId: PeerGroupUnreadCountersSummary]
|
||||
@ -55,6 +56,7 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
||||
var channelStates: [PeerId: Int32] = [:]
|
||||
var topMessageIds: [PeerId: MessageId] = [:]
|
||||
var ttlPeriods: [PeerId: CachedPeerAutoremoveTimeout] = [:]
|
||||
var hiddenTranslations: [PeerId: Bool] = [:]
|
||||
|
||||
var storeMessages: [StoreMessage] = []
|
||||
var nonPinnedDialogsTopMessageIds = Set<MessageId>()
|
||||
@ -112,6 +114,10 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
||||
|
||||
ttlPeriods[peer.peerId] = .known(ttlPeriod.flatMap(CachedPeerAutoremoveTimeout.Value.init(peerValue:)))
|
||||
|
||||
if (flags & (1 << 6)) != 0 {
|
||||
hiddenTranslations[peer.peerId] = true
|
||||
}
|
||||
|
||||
let isPinned = (flags & (1 << 2)) != 0
|
||||
if !isPinned {
|
||||
nonPinnedDialogsTopMessageIds.insert(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: topMessage))
|
||||
@ -190,6 +196,7 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message],
|
||||
topMessageIds: topMessageIds,
|
||||
storeMessages: storeMessages,
|
||||
ttlPeriods: ttlPeriods,
|
||||
hiddenTranslations: hiddenTranslations,
|
||||
|
||||
lowerNonPinnedIndex: lowerNonPinnedIndex,
|
||||
referencedFolders: referencedFolders
|
||||
@ -208,6 +215,7 @@ struct FetchedChatList {
|
||||
var channelStates: [PeerId: Int32]
|
||||
var storeMessages: [StoreMessage]
|
||||
var topMessageIds: [PeerId: MessageId]
|
||||
var hiddenTranslations: [PeerId: Bool]
|
||||
|
||||
var lowerNonPinnedIndex: MessageIndex?
|
||||
|
||||
@ -316,6 +324,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo
|
||||
var channelStates: [PeerId: Int32] = [:]
|
||||
var storeMessages: [StoreMessage] = []
|
||||
var topMessageIds: [PeerId: MessageId] = [:]
|
||||
var hiddenTranslations: [PeerId: Bool] = [:]
|
||||
|
||||
peers.append(contentsOf: parsedRemoteChats.peers)
|
||||
peerPresences.merge(parsedRemoteChats.peerPresences, uniquingKeysWith: { _, updated in updated })
|
||||
@ -327,6 +336,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo
|
||||
channelStates.merge(parsedRemoteChats.channelStates, uniquingKeysWith: { _, updated in updated })
|
||||
storeMessages.append(contentsOf: parsedRemoteChats.storeMessages)
|
||||
topMessageIds.merge(parsedRemoteChats.topMessageIds, uniquingKeysWith: { _, updated in updated })
|
||||
hiddenTranslations.merge(parsedRemoteChats.hiddenTranslations, uniquingKeysWith: { _, updated in updated })
|
||||
|
||||
if let parsedPinnedChats = parsedPinnedChats {
|
||||
peers.append(contentsOf: parsedPinnedChats.peers)
|
||||
@ -339,6 +349,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo
|
||||
channelStates.merge(parsedPinnedChats.channelStates, uniquingKeysWith: { _, updated in updated })
|
||||
storeMessages.append(contentsOf: parsedPinnedChats.storeMessages)
|
||||
topMessageIds.merge(parsedPinnedChats.topMessageIds, uniquingKeysWith: { _, updated in updated })
|
||||
hiddenTranslations.merge(parsedPinnedChats.hiddenTranslations, uniquingKeysWith: { _, updated in updated })
|
||||
}
|
||||
|
||||
var peerGroupIds: [PeerId: PeerGroupId] = [:]
|
||||
@ -362,6 +373,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo
|
||||
reactionTagSummaries.merge(folderChats.reactionTagSummaries, uniquingKeysWith: { _, updated in updated })
|
||||
channelStates.merge(folderChats.channelStates, uniquingKeysWith: { _, updated in updated })
|
||||
storeMessages.append(contentsOf: folderChats.storeMessages)
|
||||
hiddenTranslations.merge(folderChats.hiddenTranslations, uniquingKeysWith: { _, updated in updated })
|
||||
}
|
||||
|
||||
var pinnedItemIds: [PeerId]?
|
||||
@ -398,6 +410,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo
|
||||
channelStates: channelStates,
|
||||
storeMessages: storeMessages,
|
||||
topMessageIds: topMessageIds,
|
||||
hiddenTranslations: hiddenTranslations,
|
||||
|
||||
lowerNonPinnedIndex: parsedRemoteChats.lowerNonPinnedIndex,
|
||||
|
||||
|
@ -835,6 +835,19 @@ func fetchChatListHole(postbox: Postbox, network: Network, accountPeerId: PeerId
|
||||
})
|
||||
}
|
||||
|
||||
for (peerId, _) in fetchedChats.hiddenTranslations {
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
let current = (current as? CachedChannelData) ?? CachedChannelData()
|
||||
var updatedFlags = current.flags
|
||||
updatedFlags.insert(.translationHidden)
|
||||
return current.withUpdatedFlags(updatedFlags)
|
||||
} else {
|
||||
return current
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
transaction.replaceChatListHole(groupId: groupId, index: hole.index, hole: fetchedChats.lowerNonPinnedIndex.flatMap(ChatListHole.init))
|
||||
|
||||
for peerId in fetchedChats.chatPeerIds {
|
||||
|
@ -19,6 +19,7 @@ public struct CachedChannelFlags: OptionSet {
|
||||
public static let canChangePeerGeoLocation = CachedChannelFlags(rawValue: 1 << 5)
|
||||
public static let canDeleteHistory = CachedChannelFlags(rawValue: 1 << 6)
|
||||
public static let antiSpamEnabled = CachedChannelFlags(rawValue: 1 << 7)
|
||||
public static let translationHidden = CachedChannelFlags(rawValue: 1 << 8)
|
||||
}
|
||||
|
||||
public struct CachedChannelParticipantsSummary: PostboxCoding, Equatable {
|
||||
|
@ -77,6 +77,19 @@ func _internal_translateMessages(account: Account, messageIds: [EngineMessage.Id
|
||||
|
||||
func _internal_togglePeerMessagesTranslationHidden(account: Account, peerId: EnginePeer.Id, hidden: Bool) -> Signal<Never, NoError> {
|
||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, cachedData -> CachedPeerData? in
|
||||
if let cachedData = cachedData as? CachedChannelData {
|
||||
var updatedFlags = cachedData.flags
|
||||
if hidden {
|
||||
updatedFlags.insert(.translationHidden)
|
||||
} else {
|
||||
updatedFlags.remove(.translationHidden)
|
||||
}
|
||||
return cachedData.withUpdatedFlags(updatedFlags)
|
||||
} else {
|
||||
return cachedData
|
||||
}
|
||||
})
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
|
||||
|
@ -469,6 +469,9 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
||||
if (flags2 & Int32(1 << 1)) != 0 {
|
||||
channelFlags.insert(.antiSpamEnabled)
|
||||
}
|
||||
if (flags2 & Int32(1 << 3)) != 0 {
|
||||
channelFlags.insert(.translationHidden)
|
||||
}
|
||||
|
||||
let sendAsPeerId = defaultSendAs?.peerId
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user