diff --git a/submodules/AccountContext/Sources/GalleryController.swift b/submodules/AccountContext/Sources/GalleryController.swift index f51b02e584..9acf23a575 100644 --- a/submodules/AccountContext/Sources/GalleryController.swift +++ b/submodules/AccountContext/Sources/GalleryController.swift @@ -12,7 +12,7 @@ public enum GalleryControllerItemSource { } public final class GalleryControllerActionInteraction { - public let openUrl: (String, Bool) -> Void + public let openUrl: (String, Bool, Bool) -> Void public let openUrlIn: (String) -> Void public let openPeerMention: (String) -> Void public let openPeer: (EnginePeer) -> Void @@ -25,7 +25,7 @@ public final class GalleryControllerActionInteraction { public let updateCanReadHistory: (Bool) -> Void public init( - openUrl: @escaping (String, Bool) -> Void, + openUrl: @escaping (String, Bool, Bool) -> Void, openUrlIn: @escaping (String) -> Void, openPeerMention: @escaping (String) -> Void, openPeer: @escaping (EnginePeer) -> Void, diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index 1dda5f1bd5..9711282218 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -783,7 +783,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll if let (attributeText, fullText) = self.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) { concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText) } - return .url(url: url, concealed: concealed, dismiss: true) + return .url(url: url, concealed: concealed, forceExternal: false, dismiss: true) } else if let peerMention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { return .peerMention(peerMention.peerId, peerMention.mention) } else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String { diff --git a/submodules/GalleryUI/Sources/GalleryController.swift b/submodules/GalleryUI/Sources/GalleryController.swift index 3e0c9fd226..242e26bca4 100644 --- a/submodules/GalleryUI/Sources/GalleryController.swift +++ b/submodules/GalleryUI/Sources/GalleryController.swift @@ -386,7 +386,7 @@ public func galleryItemForEntry( } } if content == nil, let webEmbedContent = WebEmbedVideoContent(userLocation: .peer(message.id.peerId), webPage: webpage, webpageContent: webpageContent, forcedTimestamp: timecode.flatMap(Int.init), openUrl: { url in - performAction(.url(url: url.absoluteString, concealed: false, dismiss: true)) + performAction(.url(url: url.absoluteString, concealed: false, forceExternal: false, dismiss: true)) }) { content = webEmbedContent } @@ -504,7 +504,7 @@ private enum GalleryMessageHistoryView { } public enum GalleryControllerInteractionTapAction { - case url(url: String, concealed: Bool, dismiss: Bool) + case url(url: String, concealed: Bool, forceExternal: Bool, dismiss: Bool) case textMention(String) case peerMention(PeerId, String) case botCommand(String) @@ -960,14 +960,14 @@ public class GalleryController: ViewController, StandalonePresentableController, performActionImpl = { [weak self] action in if let strongSelf = self { - if case let .url(_, _, dismiss) = action, !dismiss { + if case let .url(_, _, _, dismiss) = action, !dismiss { } else if case .timecode = action { } else { strongSelf.dismiss(forceAway: false) } switch action { - case let .url(url, concealed, _): - strongSelf.actionInteraction?.openUrl(url, concealed) + case let .url(url, concealed, forceExternal, _): + strongSelf.actionInteraction?.openUrl(url, concealed, forceExternal) case let .textMention(mention): strongSelf.actionInteraction?.openPeerMention(mention) case let .peerMention(peerId, _): @@ -996,7 +996,7 @@ public class GalleryController: ViewController, StandalonePresentableController, presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) } switch action { - case let .url(url, _, _): + case let .url(url, _, forceExternal, _): var cleanUrl = url var canAddToReadingList = true let canOpenIn = availableOpenInOptions(context: strongSelf.context, item: .url(url: url)).count > 1 @@ -1031,7 +1031,7 @@ public class GalleryController: ViewController, StandalonePresentableController, strongSelf.actionInteraction?.openUrlIn(url) } else { strongSelf.dismiss(forceAway: false) - strongSelf.actionInteraction?.openUrl(url, false) + strongSelf.actionInteraction?.openUrl(url, false, forceExternal) } } })) diff --git a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift index d3e9451756..43b4fc922e 100644 --- a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift @@ -435,7 +435,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode { guard let strongSelf = self, let message = strongSelf.message else { return } - strongSelf.footerContentNode.openActionOptions?(.url(url: payload, concealed: true, dismiss: true), message) + strongSelf.footerContentNode.openActionOptions?(.url(url: payload, concealed: true, forceExternal: false, dismiss: true), message) } recognizedContentNode.alpha = 0.0 recognizedContentNode.frame = CGRect(origin: CGPoint(), size: size) diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index f70266e0b1..f949c7328c 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -368,7 +368,7 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN self.updateLayout(size: validLayout.size, metrics: validLayout.metrics, insets: validLayout.insets, isHidden: false, transition: .immediate) } context.engine.messages.markAdAction(opaqueId: ad.opaqueId, media: false, fullscreen: false) - self.performAction?(.url(url: ad.url, concealed: false, dismiss: false)) + self.performAction?(.url(url: ad.url, concealed: false, forceExternal: true, dismiss: false)) } }, moreAction: { [weak self] sourceNode in diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 07cb8db0b5..2858c45985 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -5599,9 +5599,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro }, callPeer: { peerId, isVideo in }, openConferenceCall: { _ in }, enqueueMessage: { _ in - }, sendSticker: nil, sendEmoji: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }, actionInteraction: GalleryControllerActionInteraction(openUrl: { [weak self] url, concealed in + }, sendSticker: nil, sendEmoji: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }, actionInteraction: GalleryControllerActionInteraction(openUrl: { [weak self] url, concealed, forceExternal in if let strongSelf = self { - strongSelf.openUrl(url: url, concealed: false, external: false) + strongSelf.openUrl(url: url, concealed: false, external: forceExternal) } }, openUrlIn: { [weak self] url in if let strongSelf = self { diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift index ef99d1a960..0d53a0d87c 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/StorageUsageScreen.swift @@ -2801,7 +2801,7 @@ final class StorageUsageScreenComponent: Component { sendEmoji: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }, - actionInteraction: GalleryControllerActionInteraction(openUrl: { [weak self] url, concealed in + actionInteraction: GalleryControllerActionInteraction(openUrl: { [weak self] url, concealed, forceExternal in guard let self else { return } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 3b6c8a1f36..e0b66d55d2 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1395,9 +1395,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G })) } }, actionInteraction: GalleryControllerActionInteraction( - openUrl: { [weak self] url, concealed in + openUrl: { [weak self] url, concealed, forceExternal in if let self { - self.openUrl(url, concealed: concealed, message: nil) + self.openUrl(url, concealed: concealed, forceExternal: forceExternal, message: nil) } }, openUrlIn: { [weak self] url in if let self {