From 8d56ab6bdc389263fae100c3d3bfd90fa5945276 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 8 Dec 2021 19:16:31 +0400 Subject: [PATCH] Disable recent stickers & gifs update in copy protected chats --- .../State/AccountStateManagementUtils.swift | 46 ++++++++++--------- .../Panes/PeerInfoVisualMediaPaneNode.swift | 8 +++- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index 9893bb20e7..a533578702 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -2578,35 +2578,39 @@ func replayFinalState( } if !message.flags.contains(.Incoming), message.forwardInfo == nil { - inner: for media in message.media { - if let file = media as? TelegramMediaFile { - for attribute in file.attributes { - switch attribute { - case let .Sticker(_, packReference, _): - if let index = message.index, packReference != nil { - if let (currentIndex, _) = recentlyUsedStickers[file.fileId] { - if currentIndex < index { + if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(message.id.peerId.namespace), let peer = transaction.getPeer(message.id.peerId), peer.isCopyProtectionEnabled { + + } else { + inner: for media in message.media { + if let file = media as? TelegramMediaFile { + for attribute in file.attributes { + switch attribute { + case let .Sticker(_, packReference, _): + if let index = message.index, packReference != nil { + if let (currentIndex, _) = recentlyUsedStickers[file.fileId] { + if currentIndex < index { + recentlyUsedStickers[file.fileId] = (index, file) + } + } else { recentlyUsedStickers[file.fileId] = (index, file) } - } else { - recentlyUsedStickers[file.fileId] = (index, file) } - } - case .Animated: - if let index = message.index { - if let (currentIndex, _) = recentlyUsedGifs[file.fileId] { - if currentIndex < index { + case .Animated: + if let index = message.index { + if let (currentIndex, _) = recentlyUsedGifs[file.fileId] { + if currentIndex < index { + recentlyUsedGifs[file.fileId] = (index, file) + } + } else { recentlyUsedGifs[file.fileId] = (index, file) } - } else { - recentlyUsedGifs[file.fileId] = (index, file) } - } - default: - break + default: + break + } } + break inner } - break inner } } } diff --git a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift index 3975bf926c..f2561c6cd8 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift @@ -2339,7 +2339,13 @@ final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScro let itemFrame = self.view.convert(self.itemGrid.frameForItem(layer: itemLayer), from: self.itemGrid.view) let proxyNode = ASDisplayNode() proxyNode.frame = itemFrame - proxyNode.contents = itemLayer.contents + if let contents = itemLayer.getContents() { + if let image = contents as? UIImage { + proxyNode.contents = image.cgImage + } else { + proxyNode.contents = contents + } + } proxyNode.isHidden = true self.addSubnode(proxyNode)