From 4ecd18e649916ab632155dc369792aba25570b0c Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 25 Oct 2023 16:56:35 +0400 Subject: [PATCH] Fix non-interactive embed preview edge case --- .../ChatMessageWebpageBubbleContentNode.swift | 15 ++++++++++++++- .../TelegramUI/Sources/ChatController.swift | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift index e241f9d3bd..b90e86da91 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift @@ -89,7 +89,20 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent case .automaticPlayback: openChatMessageMode = .automaticPlayback } - let _ = item.controllerInteraction.openMessage(item.message, openChatMessageMode) + if !item.controllerInteraction.openMessage(item.message, openChatMessageMode) { + if let webPage = strongSelf.webPage, case let .Loaded(content) = webPage.content { + var isConcealed = true + if item.message.text.contains(content.url) { + isConcealed = false + } + if let attribute = item.message.webpagePreviewAttribute { + if attribute.isSafe { + isConcealed = false + } + } + item.controllerInteraction.openUrl(ChatControllerInteraction.OpenUrl(url: content.url, concealed: isConcealed, progress: strongSelf.contentNode.makeProgress())) + } + } } } self.contentNode.activateAction = { [weak self] in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 3cc192ba82..7a8e039b3d 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -17995,8 +17995,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } else if let embedUrl = content.embedUrl, !embedUrl.isEmpty { progress?.set(.single(false)) - let _ = self.controllerInteraction?.openMessage(message, .default) - return + if let controllerInteraction = self.controllerInteraction { + if controllerInteraction.openMessage(message, .default) { + return + } + } } }