From a9798ac925b8a9d491fb928630944bd53807528c Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 4 Nov 2024 12:58:03 +0100 Subject: [PATCH 1/2] Don't display quality selector if there is only one --- .../Items/UniversalVideoGalleryItem.swift | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index c051c7cca8..2fdb9d1f9c 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -3548,39 +3548,41 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { }))) } - for quality in videoQualityState.available { - let isSelected = videoQualityState.preferred == .quality(quality) - let qualityTitle: String - if quality <= 360 { - qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityLow - } else if quality <= 480 { - qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityMedium - } else if quality <= 720 { - qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityHD - } else if quality <= 1080 { - qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityFHD - } else { - qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityQHD - } - items.append(.action(ContextMenuActionItem(text: qualityTitle, textLayout: .secondLineWithValue("\(quality)p"), icon: { _ in - if isSelected { - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: .white) + if videoQualityState.available.count > 1 { + for quality in videoQualityState.available { + let isSelected = videoQualityState.preferred == .quality(quality) + let qualityTitle: String + if quality <= 360 { + qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityLow + } else if quality <= 480 { + qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityMedium + } else if quality <= 720 { + qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityHD + } else if quality <= 1080 { + qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityFHD } else { - return nil + qualityTitle = strongSelf.presentationData.strings.Gallery_VideoSettings_QualityQHD } - }, action: { [weak self] _, f in - f(.default) - - guard let self, let videoNode = self.videoNode else { - return - } - videoNode.setVideoQuality(.quality(quality)) - self.videoQualityPromise.set(.quality(quality)) - - /*if let controller = strongSelf.galleryController() as? GalleryController { - controller.updateSharedPlaybackRate(rate) - }*/ - }))) + items.append(.action(ContextMenuActionItem(text: qualityTitle, textLayout: .secondLineWithValue("\(quality)p"), icon: { _ in + if isSelected { + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: .white) + } else { + return nil + } + }, action: { [weak self] _, f in + f(.default) + + guard let self, let videoNode = self.videoNode else { + return + } + videoNode.setVideoQuality(.quality(quality)) + self.videoQualityPromise.set(.quality(quality)) + + /*if let controller = strongSelf.galleryController() as? GalleryController { + controller.updateSharedPlaybackRate(rate) + }*/ + }))) + } } } } else { From a0152492eb922033ec630fe4a667078f2e84de80 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Mon, 4 Nov 2024 12:58:20 +0100 Subject: [PATCH 2/2] Roll back synchronize peer read state --- .../TelegramCore/Sources/State/SynchronizePeerReadState.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift b/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift index b61049a1f4..bed0706667 100644 --- a/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift +++ b/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift @@ -178,9 +178,7 @@ private func validatePeerReadState(network: Network, postbox: Postbox, stateMana if case let .idBased(updatedMaxIncomingReadId, _, _, updatedCount, updatedMarkedUnread) = readState { if updatedCount != 0 || updatedMarkedUnread { if localMaxIncomingReadId > updatedMaxIncomingReadId { - if !"".isEmpty { - return .retry - } + return .retry } } }