From 987befccc482877dfead04955022267f0e2a58d3 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 19 Sep 2024 17:47:49 +0400 Subject: [PATCH] Ads and codes improvements --- .../Sources/BrowserBookmarksScreen.swift | 3 ++- .../Sources/ChatListSearchListPaneNode.swift | 2 +- .../Sources/Node/ChatListItem.swift | 2 +- .../Sources/Node/ChatListNode.swift | 4 ++-- .../Items/UniversalVideoGalleryItem.swift | 18 +++++++++++++---- .../ZoomableContentGalleryItemNode.swift | 7 +++++++ .../Sources/ItemListAvatarAndNameItem.swift | 2 +- .../Sources/TelegramEngine/Peers/Peer.swift | 3 +++ .../Sources/Utils/PeerUtils.swift | 18 +++++++++++++++++ .../Sources/ChatMessageBubbleItemNode.swift | 2 +- .../Sources/ChatMessageDateHeader.swift | 6 ++++-- .../Sources/ChatMessageItemImpl.swift | 3 +++ .../Sources/ChatMessageNotificationItem.swift | 2 +- .../ChatMessageWebpageBubbleContentNode.swift | 2 +- .../ChatRecentActionsControllerNode.swift | 3 ++- .../ChatSendAudioMessageContextPreview.swift | 3 ++- .../Sources/ChatControllerInteraction.swift | 7 +++++-- .../ChatTitleView/Sources/ChatTitleView.swift | 10 +++++++--- .../Sources/PeerInfoScreen.swift | 3 ++- .../TelegramUI/Sources/ChatController.swift | 20 ++++++++++++++++--- .../ChatInterfaceStateContextMenus.swift | 4 ++-- .../ChatInterfaceStateInputPanels.swift | 2 +- .../ChatInterfaceStateNavigationButtons.swift | 2 +- .../OverlayAudioPlayerControllerNode.swift | 3 ++- .../Sources/SharedAccountContext.swift | 3 ++- 25 files changed, 102 insertions(+), 32 deletions(-) diff --git a/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift b/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift index cef645b788..273bd0a91f 100644 --- a/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift +++ b/submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift @@ -147,7 +147,7 @@ public final class BrowserBookmarksScreen: ViewController { }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -167,6 +167,7 @@ public final class BrowserBookmarksScreen: ViewController { }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index cd0e1be846..55526da10d 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -177,7 +177,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable { } let status: ContactsPeerItemStatus - if primaryPeer.id.isReplies { + if primaryPeer.id.isRepliesOrVerificationCodes { status = .none } else if case let .user(user) = primaryPeer { let servicePeer = isServicePeer(primaryPeer._asPeer()) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 0f3ea9d162..b86e567d5c 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -2548,7 +2548,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode { if !ignoreForwardedIcon { if case .savedMessagesChats = item.chatListLocation { displayForwardedIcon = false - } else if let forwardInfo = message.forwardInfo, !forwardInfo.flags.contains(.isImported) { + } else if let forwardInfo = message.forwardInfo, !forwardInfo.flags.contains(.isImported) && !message.id.peerId.isVerificationCodes { displayForwardedIcon = true } else if let _ = message.attributes.first(where: { $0 is ReplyStoryAttribute }) { displayStoryReplyIcon = true diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index d99c45eb76..9d7d970285 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -2298,7 +2298,7 @@ public final class ChatListNode: ListView { guard !filter.contains(.onlyPrivateChats) || peer.peerId.namespace == Namespaces.Peer.CloudUser else { return false } if let peer = peer.peer { - if peer.id.isReplies { + if peer.id.isRepliesOrVerificationCodes { return false } @@ -4249,7 +4249,7 @@ private func statusStringForPeerType(accountPeerId: EnginePeer.Id, strings: Pres } } - if peer.id.isReplies { + if peer.id.isReplies || peer.id.isVerificationCodes { return nil } else if case let .user(user) = peer { if user.botInfo != nil || user.flags.contains(.isSupport) { diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index fd7be6047b..8efcf39fdc 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -860,8 +860,11 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } self.overlayContentNode.action = { [weak self] toLandscape in - self?.updateControlsVisibility(!toLandscape) - self?.updateOrientation(toLandscape ? .landscapeRight : .portrait) + guard let self else { + return + } + self.updateControlsVisibility(!toLandscape) + self.updateOrientation(toLandscape ? .landscapeRight : .portrait) } self.statusButtonNode.addSubnode(self.statusNode) @@ -874,7 +877,6 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { if !strongSelf.isPaused { strongSelf.didPause = true } - strongSelf.videoNode?.togglePlayPause() } } @@ -1006,6 +1008,14 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } + override func contentTapAction() -> Bool { + if case let .message(message, _) = self.item?.contentInfo, let _ = message.adAttribute { + self.item?.performAction(.ad(message.id)) + return true + } + return false + } + override func screenFrameUpdated(_ frame: CGRect) { let center = frame.midX - self.frame.width / 2.0 self.subnodeTransform = CATransform3DMakeTranslation(-center * 0.16, 0.0, 0.0) @@ -1249,7 +1259,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } } let status = messageMediaFileStatus(context: item.context, messageId: message.id, file: file) - if !isWebpage { + if !isWebpage && message.adAttribute == nil { scrubberView.setFetchStatusSignal(status, strings: self.presentationData.strings, decimalSeparator: self.presentationData.dateTimeFormat.decimalSeparator, fileSize: file.size) } diff --git a/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift b/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift index fbcf016de4..f07d828144 100644 --- a/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift +++ b/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift @@ -59,12 +59,19 @@ open class ZoomableContentGalleryItemNode: GalleryItemNode, ASScrollViewDelegate self.addSubnode(self.scrollNode) } + open func contentTapAction() -> Bool { + return false + } + @objc open func contentTap(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) { if recognizer.state == .ended { if let (gesture, location) = recognizer.lastRecognizedGestureAndLocation { let pointInNode = self.scrollNode.view.convert(location, to: self.view) if pointInNode.x < 44.0 || pointInNode.x > self.frame.width - 44.0 { } else { + if self.contentTapAction() { + return + } switch gesture { case .tap: self.toggleControlsVisibility() diff --git a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift index 34a6d5ff2c..e4e335c9bc 100644 --- a/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift +++ b/submodules/ItemListAvatarAndNameInfoItem/Sources/ItemListAvatarAndNameItem.swift @@ -445,7 +445,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo } else if peer.flags.contains(.isSupport), !servicePeer { statusText = item.presentationData.strings.Bot_GenericSupportStatus statusColor = item.presentationData.theme.list.itemSecondaryTextColor - } else if peer.id.isReplies { + } else if peer.id.isRepliesOrVerificationCodes { statusText = "" statusColor = item.presentationData.theme.list.itemPrimaryTextColor } else if let _ = peer.botInfo { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift index 1f67bde1b4..97c3c609a0 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift @@ -520,6 +520,9 @@ public extension EnginePeer { if peer.id.isReplies { return true } + if peer.id.isVerificationCodes { + return true + } return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt64Value() == 777000 || peer.id.id._internalGetInt64Value() == 333000)) } return false diff --git a/submodules/TelegramCore/Sources/Utils/PeerUtils.swift b/submodules/TelegramCore/Sources/Utils/PeerUtils.swift index d993fc3d4c..0eef90a045 100644 --- a/submodules/TelegramCore/Sources/Utils/PeerUtils.swift +++ b/submodules/TelegramCore/Sources/Utils/PeerUtils.swift @@ -424,6 +424,9 @@ public func isServicePeer(_ peer: Peer) -> Bool { if peer.id.isReplies { return true } + if peer.id.isVerificationCodes { + return true + } return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt64Value() == 777000 || peer.id.id._internalGetInt64Value() == 333000)) } return false @@ -439,11 +442,26 @@ public extension PeerId { return false } + var isVerificationCodes: Bool { + if self.namespace == Namespaces.Peer.CloudUser { + if self.id._internalGetInt64Value() == 489000 { + return true + } + } + return false + } + + var isRepliesOrVerificationCodes: Bool { + return self.isReplies || self.isVerificationCodes + } + func isRepliesOrSavedMessages(accountPeerId: PeerId) -> Bool { if accountPeerId == self { return true } else if self.isReplies { return true + } else if self.isVerificationCodes { + return true } else { return false } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index eca22e7b7f..3e36c6d873 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -1641,7 +1641,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI if let _ = sourceReference { needsShareButton = true } - } else if item.message.id.peerId.isReplies { + } else if item.message.id.peerId.isRepliesOrVerificationCodes { needsShareButton = false } else if incoming { if let _ = sourceReference { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift index 5ec7990494..6df74b6802 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift @@ -754,8 +754,10 @@ public final class ChatMessageAvatarHeaderNodeImpl: ListViewItemHeaderNode, Chat if self.peerId.namespace == Namespaces.Peer.Empty, case let .message(_, _, id, _, _, _, _) = self.messageReference?.content { self.controllerInteraction?.displayMessageTooltip(id, self.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, false, self, self.avatarNode.frame) } else if let peer = self.peer { - if let adMessageId = self.adMessageId { - self.controllerInteraction?.activateAdAction(adMessageId, nil) + if peer.id.isVerificationCodes { + self.controllerInteraction?.playShakeAnimation() + } else if let adMessageId = self.adMessageId { + self.controllerInteraction?.activateAdAction(adMessageId, nil, false, false) } else { if let channel = peer as? TelegramChannel, case .broadcast = channel.info { self.controllerInteraction?.openPeer(EnginePeer(peer), .chat(textInputState: nil, subject: nil, peekData: nil), self.messageReference, .default) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift index a90de7819d..415e2065ff 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift @@ -298,6 +298,9 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil) } } + if peerId.isVerificationCodes && effectiveAuthor == nil { + effectiveAuthor = content.firstMessage.author + } displayAuthorInfo = incoming && effectiveAuthor != nil } else { effectiveAuthor = content.firstMessage.author diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageNotificationItem/Sources/ChatMessageNotificationItem.swift b/submodules/TelegramUI/Components/Chat/ChatMessageNotificationItem/Sources/ChatMessageNotificationItem.swift index 1d59686554..af8e21f43d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageNotificationItem/Sources/ChatMessageNotificationItem.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageNotificationItem/Sources/ChatMessageNotificationItem.swift @@ -167,7 +167,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode { } } var avatarPeer = peer - if firstMessage.id.peerId.isReplies, let author = firstMessage.forwardInfo?.author { + if firstMessage.id.peerId.isRepliesOrVerificationCodes, let author = firstMessage.forwardInfo?.author { avatarPeer = EnginePeer(author) } self.avatarNode.setPeer(context: item.context, theme: presentationData.theme, peer: avatarPeer, overrideImage: peer.id == item.context.account.peerId ? .savedMessagesIcon : nil, emptyColor: presentationData.theme.list.mediaPlaceholderColor) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift index 49875649c4..ba57a1641a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift @@ -118,7 +118,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent self.contentNode.activateAction = { [weak self] in if let strongSelf = self, let item = strongSelf.item { if let _ = item.message.adAttribute { - item.controllerInteraction.activateAdAction(item.message.id, strongSelf.contentNode.makeProgress()) + item.controllerInteraction.activateAdAction(item.message.id, strongSelf.contentNode.makeProgress(), false, false) } else { var webPageContent: TelegramMediaWebpageLoadedContent? for media in item.message.media { diff --git a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift index 6c39fe96db..60ee5a1eba 100644 --- a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift @@ -616,7 +616,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -637,6 +637,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: self.backgroundNode)) self.controllerInteraction = controllerInteraction diff --git a/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift b/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift index bb3a2dfabf..57f0cf7e99 100644 --- a/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift +++ b/submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift @@ -473,7 +473,7 @@ public final class ChatSendGroupMediaMessageContextPreview: UIView, ChatSendMess }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -493,6 +493,7 @@ public final class ChatSendGroupMediaMessageContextPreview: UIView, ChatSendMess }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: self.context, backgroundNode: self.wallpaperBackgroundNode)) diff --git a/submodules/TelegramUI/Components/ChatControllerInteraction/Sources/ChatControllerInteraction.swift b/submodules/TelegramUI/Components/ChatControllerInteraction/Sources/ChatControllerInteraction.swift index 1d555712bf..3f2527c6e7 100644 --- a/submodules/TelegramUI/Components/ChatControllerInteraction/Sources/ChatControllerInteraction.swift +++ b/submodules/TelegramUI/Components/ChatControllerInteraction/Sources/ChatControllerInteraction.swift @@ -252,7 +252,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol public let openLargeEmojiInfo: (String, String?, TelegramMediaFile) -> Void public let openJoinLink: (String) -> Void public let openWebView: (String, String, Bool, ChatOpenWebViewSource) -> Void - public let activateAdAction: (EngineMessage.Id, Promise?) -> Void + public let activateAdAction: (EngineMessage.Id, Promise?, Bool, Bool) -> Void public let openRequestedPeerSelection: (EngineMessage.Id, ReplyMarkupButtonRequestPeerType, Int32, Int32) -> Void public let saveMediaToFiles: (EngineMessage.Id) -> Void public let openNoAdsDemo: () -> Void @@ -273,6 +273,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol public let navigateToStory: (Message, StoryId) -> Void public let attemptedNavigationToPrivateQuote: (Peer?) -> Void public let forceUpdateWarpContents: () -> Void + public let playShakeAnimation: () -> Void public var canPlayMedia: Bool = false public var hiddenMedia: [MessageId: [Media]] = [:] @@ -382,7 +383,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol openLargeEmojiInfo: @escaping (String, String?, TelegramMediaFile) -> Void, openJoinLink: @escaping (String) -> Void, openWebView: @escaping (String, String, Bool, ChatOpenWebViewSource) -> Void, - activateAdAction: @escaping (EngineMessage.Id, Promise?) -> Void, + activateAdAction: @escaping (EngineMessage.Id, Promise?, Bool, Bool) -> Void, openRequestedPeerSelection: @escaping (EngineMessage.Id, ReplyMarkupButtonRequestPeerType, Int32, Int32) -> Void, saveMediaToFiles: @escaping (EngineMessage.Id) -> Void, openNoAdsDemo: @escaping () -> Void, @@ -402,6 +403,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol navigateToStory: @escaping (Message, StoryId) -> Void, attemptedNavigationToPrivateQuote: @escaping (Peer?) -> Void, forceUpdateWarpContents: @escaping () -> Void, + playShakeAnimation: @escaping () -> Void, automaticMediaDownloadSettings: MediaAutoDownloadSettings, pollActionState: ChatInterfacePollActionState, stickerSettings: ChatInterfaceStickerSettings, @@ -512,6 +514,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol self.navigateToStory = navigateToStory self.attemptedNavigationToPrivateQuote = attemptedNavigationToPrivateQuote self.forceUpdateWarpContents = forceUpdateWarpContents + self.playShakeAnimation = playShakeAnimation self.automaticMediaDownloadSettings = automaticMediaDownloadSettings diff --git a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift index cfd2961cb8..5d07518d22 100644 --- a/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift +++ b/submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift @@ -299,7 +299,11 @@ public final class ChatTitleView: UIView, NavigationBarTitleView { } } } - isEnabled = isEnabledValue + if peerView.peerId.isVerificationCodes { + isEnabled = false + } else { + isEnabled = isEnabledValue + } } case let .replyThread(type, count): let textFont = titleFont @@ -435,7 +439,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView { switch titleContent { case let .peer(peerView, _, _, isScheduledMessages, _, _, _): if let peer = peerView.peer { - if peer.id == self.context.account.peerId || isScheduledMessages || peer.id.isReplies { + if peer.id == self.context.account.peerId || isScheduledMessages || peer.id.isRepliesOrVerificationCodes { inputActivitiesAllowed = false } } @@ -540,7 +544,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView { state = .info(string, .generic) } else if let peer = peerView.peer { let servicePeer = isServicePeer(peer) - if peer.id == self.context.account.peerId || isScheduledMessages || peer.id.isReplies { + if peer.id == self.context.account.peerId || isScheduledMessages || peer.id.isRepliesOrVerificationCodes { let string = NSAttributedString(string: "", font: subtitleFont, textColor: titleTheme.rootController.navigationBar.secondaryTextColor) state = .info(string, .generic) } else if let user = peer as? TelegramUser { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 37a38e0da3..72710d6c80 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -3472,7 +3472,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -3492,6 +3492,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) self.hiddenMediaDisposable = context.sharedContext.mediaManager.galleryHiddenMediaManager.hiddenIds().startStrict(next: { [weak self] ids in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 8ab7dc49e5..c3d1f77ce9 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1280,6 +1280,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G standalone = true } + if let adAttribute = message.attributes.first(where: { $0 is AdMessageAttribute }) as? AdMessageAttribute { + if let file = message.media.first(where: { $0 is TelegramMediaFile}) as? TelegramMediaFile, file.isVideo && !file.isAnimated { + strongSelf.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: true, fullscreen: false) + } else { + strongSelf.controllerInteraction?.activateAdAction(message.id, nil, true, false) + return true + } + } + return context.sharedContext.openChatMessage(OpenChatMessageParams(context: context, updatedPresentationData: strongSelf.updatedPresentationData, chatLocation: openChatLocation, chatFilterTag: chatFilterTag, chatLocationContextHolder: strongSelf.chatLocationContextHolder, message: message, mediaIndex: params.mediaIndex, standalone: standalone, reverseMessageGalleryOrder: false, mode: mode, navigationController: strongSelf.effectiveNavigationController, dismissInput: { self?.chatDisplayNode.dismissInput() }, present: { c, a, i in @@ -1391,7 +1400,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } }, openAd: { [weak self] messageId in if let strongSelf = self { - strongSelf.controllerInteraction?.activateAdAction(messageId, nil) + strongSelf.controllerInteraction?.activateAdAction(messageId, nil, true, true) } }, addContact: { [weak self] phoneNumber in if let strongSelf = self { @@ -3903,7 +3912,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } self.openWebApp(buttonText: buttonText, url: url, simple: simple, source: source) - }, activateAdAction: { [weak self] messageId, progress in + }, activateAdAction: { [weak self] messageId, progress, media, fullscreen in guard let self, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId), let adAttribute = message.adAttribute else { return } @@ -3917,7 +3926,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } - self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: false, fullscreen: false) + self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: media, fullscreen: fullscreen) self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: adAttribute.url, concealed: false, external: true, progress: progress)) }, openRequestedPeerSelection: { [weak self] messageId, peerType, buttonId, maxQuantity in guard let self else { @@ -4618,6 +4627,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } self.chatDisplayNode.forceUpdateWarpContents() + }, playShakeAnimation: { [weak self] in + guard let self else { + return + } + self.playShakeAnimation() }, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: self.stickerSettings, presentationContext: ChatPresentationContext(context: context, backgroundNode: self.chatBackgroundNode)) controllerInteraction.enableFullTranslucency = context.sharedContext.energyUsageSettings.fullTranslucency diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 159114aeb2..1ca2adc044 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -298,7 +298,7 @@ func canReplyInChat(_ chatPresentationInterfaceState: ChatPresentationInterfaceS return false } - guard !peer.id.isReplies else { + guard !peer.id.isRepliesOrVerificationCodes else { return false } switch chatPresentationInterfaceState.mode { @@ -725,7 +725,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState } } - if Namespaces.Message.allNonRegular.contains(message.id.namespace) || message.id.peerId.isReplies { + if Namespaces.Message.allNonRegular.contains(message.id.namespace) || message.id.peerId.isRepliesOrVerificationCodes { canReply = false canPin = false } else if messages[0].flags.intersection([.Failed, .Unsent]).isEmpty { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift index 467dedcb39..c81bd6ea28 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift @@ -137,7 +137,7 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState var displayInputTextPanel = false if let peer = chatPresentationInterfaceState.renderedPeer?.peer { - if peer.id.isReplies { + if peer.id.isRepliesOrVerificationCodes { if let currentPanel = (currentPanel as? ChatChannelSubscriberInputPanelNode) ?? (currentSecondaryPanel as? ChatChannelSubscriberInputPanelNode) { return (currentPanel, nil) } else { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift index 32d85e591d..8e194084e2 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift @@ -171,7 +171,7 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present } } if case let .peer(peerId) = presentationInterfaceState.chatLocation { - if peerId.isReplies { + if peerId.isRepliesOrVerificationCodes { if hasMessages { if case .search = currentButton?.action { return currentButton diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index 8d9f42b048..94e55db6ee 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -165,7 +165,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -185,6 +185,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) self.dimNode = ASDisplayNode() diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index d31dfde970..6dade9a1a1 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -1776,7 +1776,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { }, openLargeEmojiInfo: { _, _, _ in }, openJoinLink: { _ in }, openWebView: { _, _, _, _ in - }, activateAdAction: { _, _ in + }, activateAdAction: { _, _, _, _ in }, openRequestedPeerSelection: { _, _, _, _ in }, saveMediaToFiles: { _ in }, openNoAdsDemo: { @@ -1796,6 +1796,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { }, navigateToStory: { _, _ in }, attemptedNavigationToPrivateQuote: { _ in }, forceUpdateWarpContents: { + }, playShakeAnimation: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(), presentationContext: ChatPresentationContext(context: context, backgroundNode: backgroundNode as? WallpaperBackgroundNode))