From 575eb2ca5f5666f32425f5ef1bc06b6000d0c411 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 20 Jan 2025 01:25:42 +0400 Subject: [PATCH] Various improvements --- .../Sources/ChatMessageInteractiveMediaNode.swift | 14 +++++++++++--- .../ChatMessageMediaBubbleContentNode.swift | 8 ++++++-- versions.json | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift index bcdf9bc7e1..aeed9b708e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift @@ -866,7 +866,9 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr } } unboundSize = CGSize(width: floor(dimensions.cgSize.width * 0.5), height: floor(dimensions.cgSize.height * 0.5)) - if file.isSticker || file.isAnimatedSticker || file.isVideoSticker { + if let image = file.videoCover, let dimensions = largestImageRepresentation(image.representations)?.dimensions { + unboundSize = CGSize(width: max(10.0, floor(dimensions.cgSize.width * 0.5)), height: max(10.0, floor(dimensions.cgSize.height * 0.5))) + } else if file.isSticker || file.isAnimatedSticker || file.isVideoSticker { unboundSize = unboundSize.aspectFilled(CGSize(width: 162.0, height: 162.0)) isSticker = true } else if file.isAnimated { @@ -1181,7 +1183,6 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr let reloadMedia = mediaUpdated || isSendingUpdated || automaticPlaybackUpdated if mediaUpdated || isSendingUpdated || automaticPlaybackUpdated || inlinePlaybackRangeUpdated { var media = media - var extendedMedia: TelegramExtendedMedia? if let invoice = media as? TelegramMediaInvoice, let selectedMedia = invoice.extendedMedia { extendedMedia = selectedMedia @@ -1472,7 +1473,14 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr return chatSecretMessageVideo(account: context.account, userLocation: .peer(message.id.peerId), videoReference: .message(message: MessageReference(message), media: file)) } } else { - if file.isAnimatedSticker { + if let file = media as? TelegramMediaFile, let image = file.videoCover { + updateImageSignal = { synchronousLoad, highQuality in + return chatMessagePhoto(postbox: context.account.postbox, userLocation: .peer(message.id.peerId), photoReference: .message(message: MessageReference(message), media: image), synchronousLoad: synchronousLoad, highQuality: highQuality) + } + updateBlurredImageSignal = { synchronousLoad, _ in + return chatSecretPhoto(account: context.account, userLocation: .peer(message.id.peerId), photoReference: .message(message: MessageReference(message), media: image), ignoreFullSize: true, synchronousLoad: true) + } + } else if file.isAnimatedSticker { let dimensions = file.dimensions ?? PixelDimensions(width: 512, height: 512) updateImageSignal = { synchronousLoad, _ in return chatMessageAnimatedSticker(postbox: context.account.postbox, userLocation: .peer(message.id.peerId), file: file, small: false, size: dimensions.cgSize.aspectFitted(CGSize(width: 400.0, height: 400.0))) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift index ce19c74bb7..6450e44497 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift @@ -170,7 +170,9 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode { automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil } } else if (telegramFile.isVideo && !telegramFile.isAnimated) && item.context.sharedContext.energyUsageSettings.autoplayVideo { - if NativeVideoContent.isHLSVideo(file: telegramFile) { + if let _ = telegramFile.videoCover { + automaticPlayback = false + } else if NativeVideoContent.isHLSVideo(file: telegramFile) { automaticPlayback = true } else if case .full = automaticDownload { automaticPlayback = true @@ -220,7 +222,9 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode { automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil } } else if (telegramFile.isVideo && !telegramFile.isAnimated) && item.context.sharedContext.energyUsageSettings.autoplayVideo { - if NativeVideoContent.isHLSVideo(file: telegramFile) { + if let _ = telegramFile.videoCover { + automaticPlayback = false + } else if NativeVideoContent.isHLSVideo(file: telegramFile) { automaticPlayback = true } else if case .full = automaticDownload { automaticPlayback = true diff --git a/versions.json b/versions.json index ab99182b79..7f456375d9 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "11.6.1", + "app": "11.7.0", "xcode": "16.0", "bazel": "7.3.1:981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff", "macos": "15.0"