From e0cac4a78bdd6583de675ee6cfe2fd3f8c98971f Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 28 Jan 2022 14:22:29 +0300 Subject: [PATCH] Various Fixes --- .../Sources/VideoStickerFrameSource.swift | 42 ------------------- .../Sources/ChannelMembersController.swift | 16 +++---- .../ChatInterfaceStateContextMenus.swift | 2 +- .../ChannelMemberCategoryListContext.swift | 2 +- 4 files changed, 11 insertions(+), 51 deletions(-) diff --git a/submodules/AnimatedStickerNode/Sources/VideoStickerFrameSource.swift b/submodules/AnimatedStickerNode/Sources/VideoStickerFrameSource.swift index 2f8b46238c..4266cfb98d 100644 --- a/submodules/AnimatedStickerNode/Sources/VideoStickerFrameSource.swift +++ b/submodules/AnimatedStickerNode/Sources/VideoStickerFrameSource.swift @@ -205,48 +205,6 @@ private final class VideoStickerFrameSourceCache { } } - func storeUncompressedYuvaFrame(index: Int, yuvaData: Data) { - if index < 0 || index >= maximumFrameCount { - return - } - if self.isStoringFrames.contains(index) { - return - } - self.isStoringFrames.insert(index) - - let width = self.width - let height = self.height - - let queue = self.queue - self.storeQueue.async { [weak self] in - let compressedData = compressFrame(width: width, height: height, yuvaData: yuvaData) - - queue.async { - guard let strongSelf = self else { - return - } - guard let currentSize = strongSelf.file.getSize() else { - return - } - guard let compressedData = compressedData else { - return - } - - strongSelf.file.seek(position: Int64(8 + index * 4 * 2)) - var offset = Int32(currentSize) - var length = Int32(compressedData.count) - let _ = strongSelf.file.write(&offset, count: 4) - let _ = strongSelf.file.write(&length, count: 4) - strongSelf.file.seek(position: Int64(currentSize)) - compressedData.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) -> Void in - if let baseAddress = buffer.baseAddress { - let _ = strongSelf.file.write(baseAddress, count: Int(length)) - } - } - } - } - } - func readUncompressedYuvaFrame(index: Int) -> Data? { if index < 0 || index >= maximumFrameCount { return nil diff --git a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift index 60698d1b76..bf2acac945 100644 --- a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift @@ -292,7 +292,7 @@ private func channelMembersControllerEntries(context: AccountContext, presentati var entries: [ChannelMembersEntry] = [] - if let participants = participants { + if let participants = participants, let contacts = contacts { var canAddMember: Bool = false if let peer = view.peers[view.peerId] as? TelegramChannel { canAddMember = peer.hasPermission(.inviteMembers) @@ -322,7 +322,7 @@ private func channelMembersControllerEntries(context: AccountContext, presentati var existingPeerIds = Set() var addedContactsHeader = false - if let contacts = contacts, !contacts.isEmpty { + if !contacts.isEmpty { addedContactsHeader = true entries.append(.contactsTitle(presentationData.theme, isGroup ? presentationData.strings.Group_Members_Contacts : presentationData.strings.Channel_Members_Contacts)) @@ -603,11 +603,13 @@ public func channelMembersController(context: AccountContext, updatedPresentatio currentPeers = peers var animateChanges = false - if let previousContacts = previousContacts, let contacts = contacts, previousContacts.count >= contacts.count { - animateChanges = true - } - if let previousPeers = previousPeers, let peers = peers, previousPeers.count >= peers.count { - animateChanges = true + if let previousContacts = previousContacts, let contacts = contacts, let previousPeers = previousPeers, let peers = peers { + if previousContacts.count >= contacts.count { + animateChanges = true + } + if previousPeers.count >= peers.count { + animateChanges = true + } } let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(isGroup ? presentationData.strings.Group_Members_Title : presentationData.strings.Channel_Subscribers_Title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, secondaryRightNavigationButton: secondaryRightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 9cc450d540..ded1a9a3a1 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -1086,7 +1086,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState } if let file = media as? TelegramMediaFile, !chatPresentationInterfaceState.copyProtectionEnabled && !message.isCopyProtected() { if file.isVideo { - if file.isAnimated { + if file.isAnimated && !file.isVideoSticker { actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_LinkDialogSave, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Save"), color: theme.actionSheet.primaryTextColor) }, action: { _, f in diff --git a/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift b/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift index 55766dd473..938705a95f 100644 --- a/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift +++ b/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift @@ -734,7 +734,7 @@ final class PeerChannelMemberCategoriesContext { let context: ChannelMemberCategoryListContext let emptyTimeout: Double switch key { - case .admins(nil), .banned(nil), .recentSearch(nil), .restricted(nil), .restrictedAndBanned(nil), .recent: + case .admins(nil), .banned(nil), .recentSearch(nil), .restricted(nil), .restrictedAndBanned(nil), .recent, .contacts: emptyTimeout = defaultEmptyTimeout default: emptyTimeout = 0.0