Merge commit '1507e99c1d785a03be868d37603f676662d90b97'

This commit is contained in:
Isaac 2025-06-29 22:23:08 +02:00
commit 1b066a3c8e
5 changed files with 34 additions and 12 deletions

View File

@ -783,7 +783,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
if let (attributeText, fullText) = self.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) { if let (attributeText, fullText) = self.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText) concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
} }
return .url(url: url, concealed: concealed) return .url(url: url, concealed: concealed, dismiss: true)
} else if let peerMention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { } else if let peerMention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
return .peerMention(peerMention.peerId, peerMention.mention) return .peerMention(peerMention.peerId, peerMention.mention)
} else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String { } else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {

View File

@ -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 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)) performAction(.url(url: url.absoluteString, concealed: false, dismiss: true))
}) { }) {
content = webEmbedContent content = webEmbedContent
} }
@ -504,7 +504,7 @@ private enum GalleryMessageHistoryView {
} }
public enum GalleryControllerInteractionTapAction { public enum GalleryControllerInteractionTapAction {
case url(url: String, concealed: Bool) case url(url: String, concealed: Bool, dismiss: Bool)
case textMention(String) case textMention(String)
case peerMention(PeerId, String) case peerMention(PeerId, String)
case botCommand(String) case botCommand(String)
@ -960,12 +960,13 @@ public class GalleryController: ViewController, StandalonePresentableController,
performActionImpl = { [weak self] action in performActionImpl = { [weak self] action in
if let strongSelf = self { if let strongSelf = self {
if case .timecode = action { if case let .url(_, _, dismiss) = action, !dismiss {
} else if case .timecode = action {
} else { } else {
strongSelf.dismiss(forceAway: false) strongSelf.dismiss(forceAway: false)
} }
switch action { switch action {
case let .url(url, concealed): case let .url(url, concealed, _):
strongSelf.actionInteraction?.openUrl(url, concealed) strongSelf.actionInteraction?.openUrl(url, concealed)
case let .textMention(mention): case let .textMention(mention):
strongSelf.actionInteraction?.openPeerMention(mention) strongSelf.actionInteraction?.openPeerMention(mention)
@ -995,7 +996,7 @@ public class GalleryController: ViewController, StandalonePresentableController,
presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme) presentationData = presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)
} }
switch action { switch action {
case let .url(url, _): case let .url(url, _, _):
var cleanUrl = url var cleanUrl = url
var canAddToReadingList = true var canAddToReadingList = true
let canOpenIn = availableOpenInOptions(context: strongSelf.context, item: .url(url: url)).count > 1 let canOpenIn = availableOpenInOptions(context: strongSelf.context, item: .url(url: url)).count > 1

View File

@ -435,7 +435,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
guard let strongSelf = self, let message = strongSelf.message else { guard let strongSelf = self, let message = strongSelf.message else {
return return
} }
strongSelf.footerContentNode.openActionOptions?(.url(url: payload, concealed: true), message) strongSelf.footerContentNode.openActionOptions?(.url(url: payload, concealed: true, dismiss: true), message)
} }
recognizedContentNode.alpha = 0.0 recognizedContentNode.alpha = 0.0
recognizedContentNode.frame = CGRect(origin: CGPoint(), size: size) recognizedContentNode.frame = CGRect(origin: CGPoint(), size: size)

View File

@ -333,6 +333,11 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN
let sideInset: CGFloat = 16.0 let sideInset: CGFloat = 16.0
var maxWidth = min(size.width, size.height) - sideInset * 2.0
if case .regular = metrics.widthClass {
maxWidth = 414.0
}
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let adSize = self.adView.update( let adSize = self.adView.update(
transition: .immediate, transition: .immediate,
@ -358,8 +363,12 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN
}, },
adAction: { [weak self] in adAction: { [weak self] in
if let self, let ad = adMessage.adAttribute { if let self, let ad = adMessage.adAttribute {
self.hiddenMessages.insert(adMessage.id)
if let validLayout = self.validLayout {
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) context.engine.messages.markAdAction(opaqueId: ad.opaqueId, media: false, fullscreen: false)
self.performAction?(.url(url: ad.url, concealed: false)) self.performAction?(.url(url: ad.url, concealed: false, dismiss: false))
} }
}, },
moreAction: { [weak self] sourceNode in moreAction: { [weak self] sourceNode in
@ -370,7 +379,7 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN
) )
), ),
environment: {}, environment: {},
containerSize: CGSize(width: size.width - sideInset * 2.0, height: 200.0) containerSize: CGSize(width: maxWidth, height: 200.0)
) )
if let adView = self.adView.view { if let adView = self.adView.view {
if adView.superview == nil { if adView.superview == nil {
@ -2091,13 +2100,17 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
if let contentInfo = item.contentInfo, case let .message(message, _) = contentInfo { if let contentInfo = item.contentInfo, case let .message(message, _) = contentInfo {
self.overlayContentNode.performAction = { [weak self] action in self.overlayContentNode.performAction = { [weak self] action in
guard let self , let item = self.item else { guard let self, let item = self.item else {
return return
} }
if case .url = action { if case .url = action {
self.pictureInPictureButtonPressed() self.pictureInPictureButtonPressed()
Queue.mainQueue().after(0.3) {
item.performAction(action)
}
} else {
item.performAction(action)
} }
item.performAction(action)
} }
self.overlayContentNode.presentPremiumDemo = { [weak self] in self.overlayContentNode.presentPremiumDemo = { [weak self] in
self?.presentPremiumDemo() self?.presentPremiumDemo()

View File

@ -328,6 +328,14 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
params.blockInteraction.set(.single(true)) params.blockInteraction.set(.single(true))
var presentInCurrent = false
if let channel = params.message.peers[params.message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
if let layout = params.navigationController?.validLayout, case .regular = layout.metrics.widthClass {
} else {
presentInCurrent = true
}
}
let _ = (gallery let _ = (gallery
|> deliverOnMainQueue).startStandalone(next: { gallery in |> deliverOnMainQueue).startStandalone(next: { gallery in
params.blockInteraction.set(.single(false)) params.blockInteraction.set(.single(false))
@ -344,7 +352,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
return nil return nil
}) })
params.present(gallery, arguments, .window(.root)) params.present(gallery, arguments, presentInCurrent ? .current : .window(.root))
}) })
return true return true
case let .secretGallery(gallery): case let .secretGallery(gallery):