diff --git a/TelegramUI/ChatController.swift b/TelegramUI/ChatController.swift index 646a80b069..19b7327d2a 100644 --- a/TelegramUI/ChatController.swift +++ b/TelegramUI/ChatController.swift @@ -1169,7 +1169,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal if let strongSelf = self { strongSelf.context.sharedContext.applicationBindings.openAppStorePage() } - }, displayMessageTooltip: { [weak self] messageId, text, sourceNode in + }, displayMessageTooltip: { [weak self] messageId, text, sourceNode, sourceFrame in if let strongSelf = self { if let sourceNode = sourceNode { strongSelf.messageTooltipController?.dismiss() @@ -1182,7 +1182,10 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal } strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { if let strongSelf = self { - let rect = sourceNode.view.convert(sourceNode.view.bounds, to: strongSelf.chatDisplayNode.view) + var rect = sourceNode.view.convert(sourceNode.view.bounds, to: strongSelf.chatDisplayNode.view) + if let sourceFrame = sourceFrame { + rect = CGRect(x: rect.minX + sourceFrame.minX, y: rect.minY + sourceFrame.minY, width: sourceFrame.width, height: sourceFrame.height) + } return (strongSelf.chatDisplayNode, rect) } return nil diff --git a/TelegramUI/ChatControllerInteraction.swift b/TelegramUI/ChatControllerInteraction.swift index 7b42d3d59d..60b53b9a73 100644 --- a/TelegramUI/ChatControllerInteraction.swift +++ b/TelegramUI/ChatControllerInteraction.swift @@ -86,7 +86,7 @@ public final class ChatControllerInteraction { let rateCall: (Message, CallId) -> Void let requestSelectMessagePollOption: (MessageId, Data) -> Void let openAppStorePage: () -> Void - let displayMessageTooltip: (MessageId, String, ASDisplayNode?) -> Void + let displayMessageTooltip: (MessageId, String, ASDisplayNode?, CGRect?) -> Void let requestMessageUpdate: (MessageId) -> Void let cancelInteractiveKeyboardGestures: () -> Void @@ -99,7 +99,7 @@ public final class ChatControllerInteraction { var pollActionState: ChatInterfacePollActionState var searchTextHighightState: String? - init(openMessage: @escaping (Message, ChatControllerInteractionOpenMessageMode) -> Bool, openPeer: @escaping (PeerId?, ChatControllerInteractionNavigateToPeer, Message?) -> Void, openPeerMention: @escaping (String) -> Void, openMessageContextMenu: @escaping (Message, Bool, ASDisplayNode, CGRect) -> Void, navigateToMessage: @escaping (MessageId, MessageId) -> Void, clickThroughMessage: @escaping () -> Void, toggleMessagesSelection: @escaping ([MessageId], Bool) -> Void, sendMessage: @escaping (String) -> Void, sendSticker: @escaping (FileMediaReference, Bool) -> Void, sendGif: @escaping (FileMediaReference) -> Void, requestMessageActionCallback: @escaping (MessageId, MemoryBuffer?, Bool) -> Void, activateSwitchInline: @escaping (PeerId?, String) -> Void, openUrl: @escaping (String, Bool, Bool?) -> Void, shareCurrentLocation: @escaping () -> Void, shareAccountContact: @escaping () -> Void, sendBotCommand: @escaping (MessageId?, String) -> Void, openInstantPage: @escaping (Message, ChatMessageItemAssociatedData?) -> Void, openWallpaper: @escaping (Message) -> Void, openHashtag: @escaping (String?, String) -> Void, updateInputState: @escaping ((ChatTextInputState) -> ChatTextInputState) -> Void, updateInputMode: @escaping ((ChatInputMode) -> ChatInputMode) -> Void, openMessageShareMenu: @escaping (MessageId) -> Void, presentController: @escaping (ViewController, Any?) -> Void, navigationController: @escaping () -> NavigationController?, presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void, callPeer: @escaping (PeerId) -> Void, longTap: @escaping (ChatControllerInteractionLongTapAction) -> Void, openCheckoutOrReceipt: @escaping (MessageId) -> Void, openSearch: @escaping () -> Void, setupReply: @escaping (MessageId) -> Void, canSetupReply: @escaping (Message) -> Bool, navigateToFirstDateMessage: @escaping(Int32) ->Void, requestRedeliveryOfFailedMessages: @escaping (MessageId) -> Void, addContact: @escaping (String) -> Void, rateCall: @escaping (Message, CallId) -> Void, requestSelectMessagePollOption: @escaping (MessageId, Data) -> Void, openAppStorePage: @escaping () -> Void, displayMessageTooltip: @escaping (MessageId, String, ASDisplayNode?) -> Void, requestMessageUpdate: @escaping (MessageId) -> Void, cancelInteractiveKeyboardGestures: @escaping () -> Void, automaticMediaDownloadSettings: MediaAutoDownloadSettings, pollActionState: ChatInterfacePollActionState) { + init(openMessage: @escaping (Message, ChatControllerInteractionOpenMessageMode) -> Bool, openPeer: @escaping (PeerId?, ChatControllerInteractionNavigateToPeer, Message?) -> Void, openPeerMention: @escaping (String) -> Void, openMessageContextMenu: @escaping (Message, Bool, ASDisplayNode, CGRect) -> Void, navigateToMessage: @escaping (MessageId, MessageId) -> Void, clickThroughMessage: @escaping () -> Void, toggleMessagesSelection: @escaping ([MessageId], Bool) -> Void, sendMessage: @escaping (String) -> Void, sendSticker: @escaping (FileMediaReference, Bool) -> Void, sendGif: @escaping (FileMediaReference) -> Void, requestMessageActionCallback: @escaping (MessageId, MemoryBuffer?, Bool) -> Void, activateSwitchInline: @escaping (PeerId?, String) -> Void, openUrl: @escaping (String, Bool, Bool?) -> Void, shareCurrentLocation: @escaping () -> Void, shareAccountContact: @escaping () -> Void, sendBotCommand: @escaping (MessageId?, String) -> Void, openInstantPage: @escaping (Message, ChatMessageItemAssociatedData?) -> Void, openWallpaper: @escaping (Message) -> Void, openHashtag: @escaping (String?, String) -> Void, updateInputState: @escaping ((ChatTextInputState) -> ChatTextInputState) -> Void, updateInputMode: @escaping ((ChatInputMode) -> ChatInputMode) -> Void, openMessageShareMenu: @escaping (MessageId) -> Void, presentController: @escaping (ViewController, Any?) -> Void, navigationController: @escaping () -> NavigationController?, presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void, callPeer: @escaping (PeerId) -> Void, longTap: @escaping (ChatControllerInteractionLongTapAction) -> Void, openCheckoutOrReceipt: @escaping (MessageId) -> Void, openSearch: @escaping () -> Void, setupReply: @escaping (MessageId) -> Void, canSetupReply: @escaping (Message) -> Bool, navigateToFirstDateMessage: @escaping(Int32) ->Void, requestRedeliveryOfFailedMessages: @escaping (MessageId) -> Void, addContact: @escaping (String) -> Void, rateCall: @escaping (Message, CallId) -> Void, requestSelectMessagePollOption: @escaping (MessageId, Data) -> Void, openAppStorePage: @escaping () -> Void, displayMessageTooltip: @escaping (MessageId, String, ASDisplayNode?, CGRect?) -> Void, requestMessageUpdate: @escaping (MessageId) -> Void, cancelInteractiveKeyboardGestures: @escaping () -> Void, automaticMediaDownloadSettings: MediaAutoDownloadSettings, pollActionState: ChatInterfacePollActionState) { self.openMessage = openMessage self.openPeer = openPeer self.openPeerMention = openPeerMention @@ -161,7 +161,7 @@ public final class ChatControllerInteraction { }, rateCall: { _, _ in }, requestSelectMessagePollOption: { _, _ in }, openAppStorePage: { - }, displayMessageTooltip: { _, _, _ in + }, displayMessageTooltip: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, diff --git a/TelegramUI/ChatMessageAnimatedStickerItemNode.swift b/TelegramUI/ChatMessageAnimatedStickerItemNode.swift index d2df99cff3..9694739d92 100644 --- a/TelegramUI/ChatMessageAnimatedStickerItemNode.swift +++ b/TelegramUI/ChatMessageAnimatedStickerItemNode.swift @@ -427,7 +427,12 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } else { navigate = .info } - item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + + if item.effectiveAuthorId?.namespace == Namespaces.Peer.Empty { + item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, self, avatarNode.frame) + } else { + item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + } } return } diff --git a/TelegramUI/ChatMessageBubbleItemNode.swift b/TelegramUI/ChatMessageBubbleItemNode.swift index 1dac09f2d8..361aa27538 100644 --- a/TelegramUI/ChatMessageBubbleItemNode.swift +++ b/TelegramUI/ChatMessageBubbleItemNode.swift @@ -1619,7 +1619,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { } else { navigate = .info } - item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + + if item.effectiveAuthorId?.namespace == Namespaces.Peer.Empty { + item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, self, avatarNode.frame) + } else { + item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + } } return } @@ -1664,7 +1669,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { } else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id { item.controllerInteraction.openPeer(id, .info, nil) } else if let _ = forwardInfo.authorSignature { - item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode) + item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } return } diff --git a/TelegramUI/ChatMessageInstantVideoItemNode.swift b/TelegramUI/ChatMessageInstantVideoItemNode.swift index 4e0a67a3c3..f601d7e197 100644 --- a/TelegramUI/ChatMessageInstantVideoItemNode.swift +++ b/TelegramUI/ChatMessageInstantVideoItemNode.swift @@ -493,7 +493,12 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { } else { navigate = .info } - item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + + if item.effectiveAuthorId?.namespace == Namespaces.Peer.Empty { + item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, self, avatarNode.frame) + } else { + item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + } } return } @@ -516,7 +521,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { } else if let id = forwardInfo.source?.id ?? forwardInfo.author?.id { item.controllerInteraction.openPeer(id, .chat(textInputState: nil, messageId: nil), nil) } else if let _ = forwardInfo.authorSignature { - item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode) + item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } return } diff --git a/TelegramUI/ChatMessageItem.swift b/TelegramUI/ChatMessageItem.swift index 4bfb3a9b9f..abd94332f0 100644 --- a/TelegramUI/ChatMessageItem.swift +++ b/TelegramUI/ChatMessageItem.swift @@ -270,13 +270,8 @@ public final class ChatMessageItem: ListViewItem, CustomStringConvertible { if peerId == context.account.peerId { if let forwardInfo = content.firstMessage.forwardInfo { effectiveAuthor = forwardInfo.author - } - if effectiveAuthor == nil { - for attribute in content.firstMessage.attributes { - if let attribute = attribute as? SourceReferenceMessageAttribute, let sourcePeer = content.firstMessage.peers[attribute.messageId.peerId] { - effectiveAuthor = sourcePeer - break - } + if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature { + effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: Int32(clamping: authorSignature.persistentHashValue)), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) } } displayAuthorInfo = incoming && effectiveAuthor != nil diff --git a/TelegramUI/ChatMessageStickerItemNode.swift b/TelegramUI/ChatMessageStickerItemNode.swift index dde843457d..e5f7a348bc 100644 --- a/TelegramUI/ChatMessageStickerItemNode.swift +++ b/TelegramUI/ChatMessageStickerItemNode.swift @@ -508,7 +508,12 @@ class ChatMessageStickerItemNode: ChatMessageItemView { } else { navigate = .info } - item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + + if item.effectiveAuthorId?.namespace == Namespaces.Peer.Empty { + item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, self, avatarNode.frame) + } else { + item.controllerInteraction.openPeer(item.effectiveAuthorId ?? author.id, navigate, item.message) + } } return } diff --git a/TelegramUI/ChatRecentActionsControllerNode.swift b/TelegramUI/ChatRecentActionsControllerNode.swift index dbe76c01cf..ba93c1a8fb 100644 --- a/TelegramUI/ChatRecentActionsControllerNode.swift +++ b/TelegramUI/ChatRecentActionsControllerNode.swift @@ -363,7 +363,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { if let strongSelf = self { strongSelf.context.sharedContext.applicationBindings.openAppStorePage() } - }, displayMessageTooltip: { _, _, _ in + }, displayMessageTooltip: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { }, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, diff --git a/TelegramUI/ItemListStickerPackItem.swift b/TelegramUI/ItemListStickerPackItem.swift index 40a8948fc1..534ca83af6 100644 --- a/TelegramUI/ItemListStickerPackItem.swift +++ b/TelegramUI/ItemListStickerPackItem.swift @@ -329,7 +329,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode { resourceReference = MediaResourceReference.standalone(resource: thumbnail.resource) } else if let item = item.topItem, let dimensions = item.file.dimensions, let resource = chatMessageStickerResource(file: item.file, small: true) as? TelegramMediaResource { thumbnailItem = TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource) - resourceReference = MediaResourceReference.standalone(resource: resource) + resourceReference = MediaResourceReference.media(media: .standalone(media: item.file), resource: resource) } let fileUpdated = thumbnailItem != previousThumbnailItem diff --git a/TelegramUI/OverlayPlayerControllerNode.swift b/TelegramUI/OverlayPlayerControllerNode.swift index 1bfaa87a79..0fdd5676a8 100644 --- a/TelegramUI/OverlayPlayerControllerNode.swift +++ b/TelegramUI/OverlayPlayerControllerNode.swift @@ -72,7 +72,7 @@ final class OverlayPlayerControllerNode: ViewControllerTracingNode, UIGestureRec }, rateCall: { _, _ in }, requestSelectMessagePollOption: { _, _ in }, openAppStorePage: { - }, displayMessageTooltip: { _, _, _ in + }, displayMessageTooltip: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, diff --git a/TelegramUI/PeerMediaCollectionController.swift b/TelegramUI/PeerMediaCollectionController.swift index b4fc1a43f8..1665d973b6 100644 --- a/TelegramUI/PeerMediaCollectionController.swift +++ b/TelegramUI/PeerMediaCollectionController.swift @@ -253,7 +253,7 @@ public class PeerMediaCollectionController: TelegramController { }, rateCall: { _, _ in }, requestSelectMessagePollOption: { _, _ in }, openAppStorePage: { - }, displayMessageTooltip: { _, _, _ in + }, displayMessageTooltip: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings,