From af9c7ed5d39f9e62f30ed93693cc18bc5b204111 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 25 Nov 2023 17:42:18 +0400 Subject: [PATCH] Various improvements --- .../Sources/AccountContext.swift | 1 + .../Sources/ChatController.swift | 10 +- .../Sources/ChatBotInfoItem.swift | 2 +- .../Sources/ChatButtonKeyboardInputNode.swift | 2 +- .../ChatMessageAnimatedStickerItemNode.swift | 2 +- .../Sources/ChatMessageBubbleItemNode.swift | 8 +- .../ChatMessageInstantVideoItemNode.swift | 2 +- ...atMessageInteractiveInstantVideoNode.swift | 2 +- .../Sources/ChatMessageDateHeader.swift | 2 +- .../Sources/ChatMessageItemView.swift | 2 +- ...essageJoinedChannelBubbleContentNode.swift | 134 +++++++++++++++--- .../Sources/ChatMessageStickerItemNode.swift | 2 +- .../Sources/ChatNavigationButton.swift | 2 +- .../ChatTextInputMediaRecordingButton.swift | 10 +- .../MessageInputActionButtonComponent.swift | 1 + .../Sources/PeerInfoPaneContainerNode.swift | 11 +- .../Sources/PeerInfoScreen.swift | 12 +- .../PeerRecommendedChannelsScreen.swift | 1 - ...StoryItemSetContainerViewSendMessage.swift | 2 +- .../TelegramUI/Sources/ChatController.swift | 29 ++-- .../ChatPinnedMessageTitlePanelNode.swift | 2 +- .../TelegramUI/Sources/OpenChatMessage.swift | 2 +- .../TelegramUI/Sources/OpenResolvedUrl.swift | 2 +- .../Sources/SharedAccountContext.swift | 8 +- .../UrlHandling/Sources/UrlHandling.swift | 8 +- 25 files changed, 190 insertions(+), 69 deletions(-) delete mode 100644 submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerRecommendedChannelsScreen.swift diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 9df210ed15..e100375512 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -543,6 +543,7 @@ public enum PeerInfoControllerMode { case group(PeerId) case reaction(MessageId) case forumTopic(thread: ChatReplyThreadMessage) + case recommendedChannels } public enum ContactListActionItemInlineIconPosition { diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index 3f5317543f..4f4da613da 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -261,9 +261,17 @@ public struct ChatControllerInitialBotAppStart { } public enum ChatControllerInteractionNavigateToPeer { + public struct InfoParams { + public let switchToRecommendedChannels: Bool + + public init(switchToRecommendedChannels: Bool) { + self.switchToRecommendedChannels = switchToRecommendedChannels + } + } + case `default` case chat(textInputState: ChatTextInputState?, subject: ChatControllerSubject?, peekData: ChatPeekTimeout?) - case info + case info(InfoParams?) case withBotStartPayload(ChatControllerInitialBotStart) case withAttachBot(ChatControllerInitialAttachBotStart) case withBotApp(ChatControllerInitialBotAppStart) diff --git a/submodules/TelegramUI/Components/Chat/ChatBotInfoItem/Sources/ChatBotInfoItem.swift b/submodules/TelegramUI/Components/Chat/ChatBotInfoItem/Sources/ChatBotInfoItem.swift index c755c7aa44..6a9820e0eb 100644 --- a/submodules/TelegramUI/Components/Chat/ChatBotInfoItem/Sources/ChatBotInfoItem.swift +++ b/submodules/TelegramUI/Components/Chat/ChatBotInfoItem/Sources/ChatBotInfoItem.swift @@ -459,7 +459,7 @@ public final class ChatBotInfoItemNode: ListViewItemNode { case let .peerMention(peerId, _, _): if let item = self.item { let _ = (item.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) - |> deliverOnMainQueue).startStandalone(next: { [weak self] peer in + |> deliverOnMainQueue).startStandalone(next: { [weak self] peer in if let peer = peer { self?.item?.controllerInteraction.openPeer(peer, .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } diff --git a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift index 3c7dfab0a4..348fc553ec 100644 --- a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift @@ -430,7 +430,7 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode { guard let self, let peer else { return } - self.controllerInteraction.openPeer(peer, .info, nil, .default) + self.controllerInteraction.openPeer(peer, .info(nil), nil, .default) }) case let .openWebView(url, simple): self.controllerInteraction.openWebView(markupButton.title, url, simple, .generic) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift index 35657bfd4b..b442a2b113 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -2072,7 +2072,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { } item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId, NavigateToMessageParams(timestamp: nil, quote: nil)) } else if let peer = forwardInfo.source ?? forwardInfo.author { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 17a7bfac59..1e906fd968 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -4244,7 +4244,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId, NavigateToMessageParams(timestamp: nil, quote: nil)) } else if let peer = forwardInfo.source ?? forwardInfo.author { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } @@ -4264,7 +4264,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } else { if let peer = item.message.peers[story.storyId.peerId] { return .action(InternalBubbleTapAction.Action { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) }) } } @@ -4318,7 +4318,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI let _ = (item.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).startStandalone(next: { peer in if let self = self, let item = self.item, let peer = peer { - item.controllerInteraction.openPeer(peer, openProfile ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(peer, openProfile ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } }) } @@ -4983,7 +4983,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI if let channel = peer as? TelegramChannel, case .broadcast = channel.info { item.controllerInteraction.openPeer(EnginePeer(peer), .chat(textInputState: nil, subject: nil, peekData: nil), messageReference, .default) } else { - item.controllerInteraction.openPeer(EnginePeer(peer), .info, messageReference, .groupParticipant(storyStats: nil, avatarHeaderNode: nil)) + item.controllerInteraction.openPeer(EnginePeer(peer), .info(nil), messageReference, .groupParticipant(storyStats: nil, avatarHeaderNode: nil)) } } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift index b4345b6166..e0e3ebe07f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInstantVideoItemNode/Sources/ChatMessageInstantVideoItemNode.swift @@ -988,7 +988,7 @@ public class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureReco } item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId, NavigateToMessageParams(timestamp: nil, quote: nil)) } else if let peer = forwardInfo.source ?? forwardInfo.author { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift index 210ea2bc00..43b476f3ca 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageInteractiveInstantVideoNode/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -1379,7 +1379,7 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId, NavigateToMessageParams(timestamp: nil, quote: nil)) return } else if let peer = forwardInfo.source ?? forwardInfo.author { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) return } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift index 1f9dc25472..f04cc06496 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageDateHeader.swift @@ -735,7 +735,7 @@ public final class ChatMessageAvatarHeaderNodeImpl: ListViewItemHeaderNode, Chat 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) } else { - self.controllerInteraction.openPeer(EnginePeer(peer), .info, self.messageReference, .groupParticipant(storyStats: nil, avatarHeaderNode: self)) + self.controllerInteraction.openPeer(EnginePeer(peer), .info(nil), self.messageReference, .groupParticipant(storyStats: nil, avatarHeaderNode: self)) } } } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift index fdc9de3bbe..81957907ff 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift @@ -823,7 +823,7 @@ open class ChatMessageItemView: ListViewItemNode, ChatMessageItemNodeProtocol { let _ = (item.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).startStandalone(next: { peer in if let peer = peer { - item.controllerInteraction.openPeer(peer, .info, nil, .default) + item.controllerInteraction.openPeer(peer, .info(nil), nil, .default) } }) case let .openWebView(url, simple): diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift index 64c020dda5..7b354c8096 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode/Sources/ChatMessageJoinedChannelBubbleContentNode.swift @@ -357,8 +357,21 @@ public class ChatMessageJoinedChannelBubbleContentNode: ChatMessageBubbleContent item.controllerInteraction.presentControllerInCurrent(controller, nil) } }, - contextAction: { peer, sourceView, gesture in - item.controllerInteraction.openRecommendedChannelContextMenu(peer, sourceView, gesture) + openMore: { [weak self] in + guard let item = self?.item else { + return + } + let _ = (item.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: item.message.id.peerId)) + |> deliverOnMainQueue).startStandalone(next: { [weak self] peer in + if let peer = peer { + self?.item?.controllerInteraction.openPeer(peer, .info(ChatControllerInteractionNavigateToPeer.InfoParams(switchToRecommendedChannels: true)), nil, .default) + } + }) + }, + contextAction: { [weak self] peer, sourceView, gesture in + if let item = self?.item { + item.controllerInteraction.openRecommendedChannelContextMenu(peer, sourceView, gesture) + } } ) ), @@ -531,6 +544,11 @@ private class MessageBackgroundNode: ASDisplayNode { private let itemSize = CGSize(width: 84.0, height: 90.0) private final class ChannelItemComponent: Component { + class ExternalState { + var cachedPlaceholderImage: UIImage? + } + + let externalState: ExternalState let context: AccountContext let theme: PresentationTheme let strings: PresentationStrings @@ -539,9 +557,11 @@ private final class ChannelItemComponent: Component { let title: String let subtitle: String let action: (EnginePeer?) -> Void + let openMore: () -> Void let contextAction: ((EnginePeer, UIView, ContextGesture?) -> Void)? init( + externalState: ExternalState, context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, @@ -550,8 +570,10 @@ private final class ChannelItemComponent: Component { title: String, subtitle: String, action: @escaping (EnginePeer?) -> Void, + openMore: @escaping () -> Void, contextAction: ((EnginePeer, UIView, ContextGesture?) -> Void)? ) { + self.externalState = externalState self.context = context self.theme = theme self.strings = strings @@ -560,6 +582,7 @@ private final class ChannelItemComponent: Component { self.title = title self.subtitle = subtitle self.action = action + self.openMore = openMore self.contextAction = contextAction } @@ -592,8 +615,7 @@ private final class ChannelItemComponent: Component { private let title = ComponentView() private let subtitle = ComponentView() - private let circleView: UIImageView - private let circleView2: UIImageView + private let circlesView: UIImageView private let avatarNode: AvatarNode private var mergedAvatarsNode: MergedAvatarsNode? @@ -606,16 +628,7 @@ private final class ChannelItemComponent: Component { override init(frame: CGRect) { self.contextContainer = ContextControllerSourceView() - self.circleView = UIImageView(image: UIImage(bundleImageName: "Avatar/SampleAvatar1")) - self.circleView.clipsToBounds = true - self.circleView.layer.cornerRadius = 30 - self.circleView.clipsToBounds = true - self.circleView.layer.cornerRadius = 30 - - let colors: NSArray = [UIColor(rgb: 0x000000).cgColor, UIColor(rgb: 0x6a2267).cgColor] - self.circleView2 = UIImageView(image: generateGradientFilledCircleImage(diameter: 60, colors: colors)) - self.circleView2.clipsToBounds = true - self.circleView2.layer.cornerRadius = 30 + self.circlesView = UIImageView() self.avatarNode = AvatarNode(font: avatarPlaceholderFont(size: 26.0)) self.avatarNode.isUserInteractionEnabled = false @@ -630,8 +643,6 @@ private final class ChannelItemComponent: Component { self.contextContainer.addSubview(self.containerButton) - self.contextContainer.addSubview(self.circleView2) - self.contextContainer.addSubview(self.circleView) self.contextContainer.addSubnode(self.avatarNode) self.contextContainer.addSubview(self.avatarBadge) @@ -655,7 +666,11 @@ private final class ChannelItemComponent: Component { return } if !component.isLocked { - component.action(peer) + if component.peers.count > 1 { + component.openMore() + } else { + component.action(peer) + } } else { component.action(nil) } @@ -739,6 +754,7 @@ private final class ChannelItemComponent: Component { mergedAvatarsNode = current } else { mergedAvatarsNode = MergedAvatarsNode() + mergedAvatarsNode.isUserInteractionEnabled = false self.contextContainer.insertSubview(mergedAvatarsNode.view, aboveSubview: self.avatarNode.view) self.mergedAvatarsNode = mergedAvatarsNode } @@ -755,14 +771,80 @@ private final class ChannelItemComponent: Component { } if component.isLocked { - self.circleView.isHidden = false - self.circleView.frame = avatarFrame.offsetBy(dx: 10.0, dy: 0.0) - self.circleView2.frame = avatarFrame.offsetBy(dx: 20.0, dy: 0.0) + if self.circlesView.superview == nil { + self.contextContainer.insertSubview(self.circlesView, belowSubview: self.avatarNode.view) + } + self.circlesView.isHidden = false - self.circleView2.isHidden = false + if self.circlesView.image == nil { + if let current = component.externalState.cachedPlaceholderImage { + self.circlesView.image = current + } else { + let image = generateImage(CGSize(width: 50.0, height: avatarSize.height), rotatedContext: { size, context in + context.clear(CGRect(origin: .zero, size: size)) + + let randomColors: [(UInt32, UInt32)] = [ + (0x4493de, 0x52d5d9), + (0xfcc418, 0xf6774a), + (0xffc9a2, 0xfbedb2), + (0x133e88, 0x131925), + (0x63c7f0, 0xf6c506), + (0x88a5cb, 0x162639), + (0xd669ed, 0xe0a2f3), + (0x54cb68, 0xa0de7e) + ] + + context.saveGState() + + let rect1 = CGRect(origin: CGPoint(x: size.width - avatarSize.width, y: 0.0), size: avatarSize) + context.addEllipse(in: rect1) + context.clip() + + var firstColors: NSArray = [] + if let random = randomColors.randomElement() { + firstColors = [UIColor(rgb: random.0).cgColor, UIColor(rgb: random.1).cgColor] + } + var locations: [CGFloat] = [1.0, 0.0] + + let colorSpace = CGColorSpaceCreateDeviceRGB() + let firstGradient = CGGradient(colorsSpace: colorSpace, colors: firstColors as CFArray, locations: &locations)! + context.drawLinearGradient(firstGradient, start: CGPoint(x: rect1.minX, y: rect1.minY), end: CGPoint(x: rect1.maxX, y: rect1.maxY), options: CGGradientDrawingOptions()) + + context.restoreGState() + + context.setBlendMode(.clear) + context.fillEllipse(in: CGRect(origin: CGPoint(x: size.width - avatarSize.width - 12.0, y: -2.0), size: CGSize(width: avatarSize.width + 4.0, height: avatarSize.height + 4.0))) + + context.setBlendMode(.normal) + + context.saveGState() + + let rect2 = CGRect(origin: CGPoint(x: size.width - avatarSize.width - 10.0, y: 0.0), size: avatarSize) + context.addEllipse(in: rect2) + context.clip() + + var secondColors: NSArray = [] + if let random = randomColors.randomElement() { + secondColors = [UIColor(rgb: random.0).cgColor, UIColor(rgb: random.1).cgColor] + } + + let secondGradient = CGGradient(colorsSpace: colorSpace, colors: secondColors as CFArray, locations: &locations)! + context.drawLinearGradient(secondGradient, start: CGPoint(x: rect2.minX, y: rect2.minY), end: CGPoint(x: rect2.minX, y: rect2.maxY), options: CGGradientDrawingOptions()) + + context.restoreGState() + + context.setBlendMode(.clear) + context.fillEllipse(in: CGRect(origin: CGPoint(x: size.width - avatarSize.width - 22.0, y: -2.0), size: CGSize(width: avatarSize.width + 4.0, height: avatarSize.height + 4.0))) + }) + component.externalState.cachedPlaceholderImage = image + self.circlesView.image = image + } + } + self.circlesView.frame = CGRect(origin: CGPoint(x: avatarFrame.midX, y: 0.0), size: CGSize(width: 50.0, height: 60.0)) } else { - self.circleView.isHidden = true - self.circleView2.isHidden = true + if self.circlesView.superview != nil { + self.circlesView.removeFromSuperview() + } } if let titleView = self.title.view { @@ -821,6 +903,7 @@ final class ChannelListPanelComponent: Component { let strings: PresentationStrings let peers: RecommendedChannels let action: (EnginePeer?) -> Void + let openMore: () -> Void let contextAction: (EnginePeer, UIView, ContextGesture?) -> Void init( @@ -829,6 +912,7 @@ final class ChannelListPanelComponent: Component { strings: PresentationStrings, peers: RecommendedChannels, action: @escaping (EnginePeer?) -> Void, + openMore: @escaping () -> Void, contextAction: @escaping (EnginePeer, UIView, ContextGesture?) -> Void ) { self.context = context @@ -836,6 +920,7 @@ final class ChannelListPanelComponent: Component { self.strings = strings self.peers = peers self.action = action + self.openMore = openMore self.contextAction = contextAction } @@ -906,6 +991,7 @@ final class ChannelListPanelComponent: Component { private let measureItem = ComponentView() private var visibleItems: [EnginePeer.Id: ComponentView] = [:] + private var externalState = ChannelItemComponent.ExternalState() private var ignoreScrolling: Bool = false @@ -1006,6 +1092,7 @@ final class ChannelListPanelComponent: Component { let _ = itemView.update( transition: itemTransition, component: AnyComponent(ChannelItemComponent( + externalState: self.externalState, context: component.context, theme: component.theme, strings: component.strings, @@ -1014,6 +1101,7 @@ final class ChannelListPanelComponent: Component { title: title, subtitle: subtitle, action: component.action, + openMore: component.openMore, contextAction: !isLocked && peers.count == 1 ? component.contextAction : nil )), environment: {}, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift index 8d510a51b1..1772b20bb7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageStickerItemNode/Sources/ChatMessageStickerItemNode.swift @@ -1400,7 +1400,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView { } item.controllerInteraction.navigateToMessage(item.message.id, sourceMessageId, NavigateToMessageParams(timestamp: nil, quote: nil)) } else if let peer = forwardInfo.source ?? forwardInfo.author { - item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) + item.controllerInteraction.openPeer(EnginePeer(peer), peer is TelegramUser ? .info(nil) : .chat(textInputState: nil, subject: nil, peekData: nil), nil, .default) } else if let _ = forwardInfo.authorSignature { item.controllerInteraction.displayMessageTooltip(item.message.id, item.presentationData.strings.Conversation_ForwardAuthorHiddenTooltip, forwardInfoNode, nil) } diff --git a/submodules/TelegramUI/Components/Chat/ChatNavigationButton/Sources/ChatNavigationButton.swift b/submodules/TelegramUI/Components/Chat/ChatNavigationButton/Sources/ChatNavigationButton.swift index 3feb62f0d8..d273af5b4e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatNavigationButton/Sources/ChatNavigationButton.swift +++ b/submodules/TelegramUI/Components/Chat/ChatNavigationButton/Sources/ChatNavigationButton.swift @@ -2,7 +2,7 @@ import Foundation import UIKit public enum ChatNavigationButtonAction: Equatable { - case openChatInfo(expandAvatar: Bool) + case openChatInfo(expandAvatar: Bool, recommendedChannels: Bool) case clearHistory case clearCache case cancelMessageSelection diff --git a/submodules/TelegramUI/Components/ChatTextInputMediaRecordingButton/Sources/ChatTextInputMediaRecordingButton.swift b/submodules/TelegramUI/Components/ChatTextInputMediaRecordingButton/Sources/ChatTextInputMediaRecordingButton.swift index 8a9cc893bc..9f932b44cf 100644 --- a/submodules/TelegramUI/Components/ChatTextInputMediaRecordingButton/Sources/ChatTextInputMediaRecordingButton.swift +++ b/submodules/TelegramUI/Components/ChatTextInputMediaRecordingButton/Sources/ChatTextInputMediaRecordingButton.swift @@ -212,6 +212,14 @@ public final class ChatTextInputMediaRecordingButton: TGModernConversationInputM } } + public var hidesOnLock: Bool = false { + didSet { + if self.hidesOnLock { + self.setHidesPanelOnLock() + } + } + } + private func updateShadow() { if let view = self.animationView.view { if self.hasShadow { @@ -340,8 +348,6 @@ public final class ChatTextInputMediaRecordingButton: TGModernConversationInputM self.updateMode(mode: self.mode, animated: false, force: true) - self.setHidesPanelOnLock() - self.delegate = self self.isExclusiveTouch = false; diff --git a/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift b/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift index 8c6ede805b..9698490cdf 100644 --- a/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputActionButtonComponent/Sources/MessageInputActionButtonComponent.swift @@ -599,6 +599,7 @@ public final class MessageInputActionButtonComponent: Component { if let micButton = self.micButton { micButton.hasShadow = component.hasShadow + micButton.hidesOnLock = component.hasShadow if themeUpdated { micButton.updateTheme(theme: defaultDarkPresentationTheme) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift index e4a9976c56..6600a16ca0 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift @@ -498,13 +498,16 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegat private var currentAvailablePanes: [PeerInfoPaneKey]? private let updatedPresentationData: (initial: PresentationData, signal: Signal)? - init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, isMediaOnly: Bool) { + private let initialPaneKey: PeerInfoPaneKey? + + init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, isMediaOnly: Bool, initialPaneKey: PeerInfoPaneKey?) { self.context = context self.updatedPresentationData = updatedPresentationData self.peerId = peerId self.chatLocation = chatLocation self.chatLocationContextHolder = chatLocationContextHolder self.isMediaOnly = isMediaOnly + self.initialPaneKey = initialPaneKey self.additionalBackgroundNode = ASDisplayNode() @@ -730,7 +733,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegat self.pendingSwitchToPaneKey = nil } } else if self.currentPaneKey == nil { - self.pendingSwitchToPaneKey = availablePanes.first + self.pendingSwitchToPaneKey = self.initialPaneKey ?? availablePanes.first } let currentIndex: Int? @@ -785,13 +788,13 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegat } for key in requiredPendingKeys { - if self.pendingPanes[key] == nil { + if self.pendingPanes[key] == nil, let data { var leftScope = false let pane = PeerInfoPendingPane( context: self.context, updatedPresentationData: self.updatedPresentationData, chatControllerInteraction: self.chatControllerInteraction!, - data: data!, + data: data, openPeerContextAction: { [weak self] recommended, peer, node, gesture in self?.openPeerContextAction?(recommended, peer, node, gesture) }, diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index b7c1b0be4f..a0010b7caf 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -2233,7 +2233,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro } private var didSetReady = false - init(controller: PeerInfoScreenImpl, context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, nearbyPeerDistance: Int32?, reactionSourceMessageId: MessageId?, callMessages: [Message], isSettings: Bool, hintGroupInCommon: PeerId?, requestsContext: PeerInvitationImportersContext?, chatLocation: ChatLocation, chatLocationContextHolder: Atomic) { + init(controller: PeerInfoScreenImpl, context: AccountContext, peerId: PeerId, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, nearbyPeerDistance: Int32?, reactionSourceMessageId: MessageId?, callMessages: [Message], isSettings: Bool, hintGroupInCommon: PeerId?, requestsContext: PeerInvitationImportersContext?, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, initialPaneKey: PeerInfoPaneKey?) { self.controller = controller self.context = context self.peerId = peerId @@ -2257,7 +2257,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro forumTopicThreadId = Int64(message.messageId.id) } self.headerNode = PeerInfoHeaderNode(context: context, controller: controller, avatarInitiallyExpanded: avatarInitiallyExpanded, isOpenedFromChat: isOpenedFromChat, isMediaOnly: self.isMediaOnly, isSettings: isSettings, forumTopicThreadId: forumTopicThreadId, chatLocation: self.chatLocation) - self.paneContainerNode = PeerInfoPaneContainerNode(context: context, updatedPresentationData: controller.updatedPresentationData, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, isMediaOnly: self.isMediaOnly) + self.paneContainerNode = PeerInfoPaneContainerNode(context: context, updatedPresentationData: controller.updatedPresentationData, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, isMediaOnly: self.isMediaOnly, initialPaneKey: initialPaneKey) super.init() @@ -9138,7 +9138,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro } } else if let currentPaneKey = self.paneContainerNode.currentPaneKey, case .members = currentPaneKey { self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, mode: .list, placeholder: self.presentationData.strings.Common_Search, hasBackground: true, hasSeparator: true, contentNode: ChannelMembersSearchContainerNode(context: self.context, forceTheme: nil, peerId: self.peerId, mode: .searchMembers, filters: [], searchContext: self.groupMembersSearchContext, openPeer: { [weak self] peer, participant in - self?.openPeer(peerId: peer.id, navigation: .info) + self?.openPeer(peerId: peer.id, navigation: .info(nil)) }, updateActivity: { _ in }, pushController: { [weak self] c in self?.controller?.push(c) @@ -10283,6 +10283,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc private let isSettings: Bool private let hintGroupInCommon: PeerId? private weak var requestsContext: PeerInvitationImportersContext? + private let switchToRecommendedChannels: Bool private let chatLocation: ChatLocation private let chatLocationContextHolder = Atomic(value: nil) @@ -10331,7 +10332,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc private var validLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)? - public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, nearbyPeerDistance: Int32?, reactionSourceMessageId: MessageId?, callMessages: [Message], isSettings: Bool = false, hintGroupInCommon: PeerId? = nil, requestsContext: PeerInvitationImportersContext? = nil, forumTopicThread: ChatReplyThreadMessage? = nil) { + public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, nearbyPeerDistance: Int32?, reactionSourceMessageId: MessageId?, callMessages: [Message], isSettings: Bool = false, hintGroupInCommon: PeerId? = nil, requestsContext: PeerInvitationImportersContext? = nil, forumTopicThread: ChatReplyThreadMessage? = nil, switchToRecommendedChannels: Bool = false) { self.context = context self.updatedPresentationData = updatedPresentationData self.peerId = peerId @@ -10343,6 +10344,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc self.isSettings = isSettings self.hintGroupInCommon = hintGroupInCommon self.requestsContext = requestsContext + self.switchToRecommendedChannels = switchToRecommendedChannels if let forumTopicThread = forumTopicThread { self.chatLocation = .replyThread(message: forumTopicThread) @@ -10659,7 +10661,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc } override public func loadDisplayNode() { - self.displayNode = PeerInfoScreenNode(controller: self, context: self.context, peerId: self.peerId, avatarInitiallyExpanded: self.avatarInitiallyExpanded, isOpenedFromChat: self.isOpenedFromChat, nearbyPeerDistance: self.nearbyPeerDistance, reactionSourceMessageId: self.reactionSourceMessageId, callMessages: self.callMessages, isSettings: self.isSettings, hintGroupInCommon: self.hintGroupInCommon, requestsContext: self.requestsContext, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder) + self.displayNode = PeerInfoScreenNode(controller: self, context: self.context, peerId: self.peerId, avatarInitiallyExpanded: self.avatarInitiallyExpanded, isOpenedFromChat: self.isOpenedFromChat, nearbyPeerDistance: self.nearbyPeerDistance, reactionSourceMessageId: self.reactionSourceMessageId, callMessages: self.callMessages, isSettings: self.isSettings, hintGroupInCommon: self.hintGroupInCommon, requestsContext: self.requestsContext, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder, initialPaneKey: self.switchToRecommendedChannels ? .recommended : nil) self.controllerNode.accountsAndPeers.set(self.accountsAndPeers.get() |> map { $0.1 }) self.controllerNode.activeSessionsContextAndCount.set(self.activeSessionsContextAndCount.get()) self.cachedDataPromise.set(self.controllerNode.cachedDataPromise.get()) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerRecommendedChannelsScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerRecommendedChannelsScreen.swift deleted file mode 100644 index fecc4ab449..0000000000 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerRecommendedChannelsScreen.swift +++ /dev/null @@ -1 +0,0 @@ -import Foundation diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index b7592cdde3..832c3c040a 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -2798,7 +2798,7 @@ final class StoryItemSetContainerSendMessage { if let peer = peer { var navigation: ChatControllerInteractionNavigateToPeer if let peer = peer as? TelegramUser, peer.botInfo == nil { - navigation = .info + navigation = .info(nil) } else { navigation = .chat(textInputState: nil, subject: nil, peekData: nil) } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 2245a76c00..e7e4c88d46 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -3607,7 +3607,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/User"), color: theme.actionSheet.primaryTextColor) }, action: { _, f in f(.dismissWithoutContent) - self?.openPeer(peer: peer, navigation: .info, fromMessage: nil) + self?.openPeer(peer: peer, navigation: .info(nil), fromMessage: nil) })) ] items.append(.action(ContextMenuActionItem(text: isChannel ? strongSelf.presentationData.strings.Conversation_ContextMenuOpenChannel : strongSelf.presentationData.strings.Conversation_ContextMenuSendMessage, icon: { theme in @@ -4744,7 +4744,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Info"), color: theme.actionSheet.primaryTextColor) }, action: { _, f in f(.dismissWithoutContent) - self?.navigationButtonAction(.openChatInfo(expandAvatar: true)) + self?.navigationButtonAction(.openChatInfo(expandAvatar: true, recommendedChannels: false)) })) ] if canViewStats { @@ -4793,7 +4793,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } chatInfoButtonItem.target = self chatInfoButtonItem.action = #selector(self.rightNavigationButtonAction) - self.chatInfoNavigationButton = ChatNavigationButton(action: .openChatInfo(expandAvatar: true), buttonItem: chatInfoButtonItem) + self.chatInfoNavigationButton = ChatNavigationButton(action: .openChatInfo(expandAvatar: true, recommendedChannels: false), buttonItem: chatInfoButtonItem) self.moreBarButton.setContent(.more(MoreHeaderButton.optionsCircleImage(color: self.presentationData.theme.rootController.navigationBar.buttonColor))) self.moreInfoNavigationButton = ChatNavigationButton(action: .toggleInfoPanel, buttonItem: UIBarButtonItem(customDisplayNode: self.moreBarButton)!) @@ -4810,7 +4810,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.navigationItem.titleView = self.chatTitleView self.chatTitleView?.pressed = { [weak self] in - self?.navigationButtonAction(.openChatInfo(expandAvatar: false)) + self?.navigationButtonAction(.openChatInfo(expandAvatar: false, recommendedChannels: false)) } self.updateChatPresentationInterfaceState(animated: false, interactive: false, { state in @@ -9057,7 +9057,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } }) }, openPeerInfo: { [weak self] in - self?.navigationButtonAction(.openChatInfo(expandAvatar: false)) + self?.navigationButtonAction(.openChatInfo(expandAvatar: false, recommendedChannels: false)) }, togglePeerNotifications: { [weak self] in if let strongSelf = self, let peerId = strongSelf.chatLocation.peerId { let _ = strongSelf.context.engine.peers.togglePeerMuted(peerId: peerId, threadId: strongSelf.chatLocation.threadId).startStandalone() @@ -11878,7 +11878,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G @objc func rightNavigationButtonAction() { if let button = self.rightNavigationButton { - if case let .peer(peerId) = self.chatLocation, case .openChatInfo(expandAvatar: true) = button.action, let storyStats = self.storyStats, storyStats.unseenCount != 0, let avatarNode = self.avatarNode { + if case let .peer(peerId) = self.chatLocation, case .openChatInfo(expandAvatar: true, _) = button.action, let storyStats = self.storyStats, storyStats.unseenCount != 0, let avatarNode = self.avatarNode { self.openStories(peerId: peerId, avatarHeaderNode: nil, avatarNode: avatarNode.avatarNode) } else { self.navigationButtonAction(button.action) @@ -12186,7 +12186,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.present(actionSheet, in: .window(.root)) }) } - case let .openChatInfo(expandAvatar): + case let .openChatInfo(expandAvatar, recommendedChannels): let _ = self.presentVoiceMessageDiscardAlert(action: { switch self.chatLocationInfoData { case let .peer(peerView): @@ -12206,7 +12206,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let validLayout = strongSelf.validLayout, validLayout.deviceMetrics.type == .tablet { expandAvatar = false } - if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true, requestsContext: strongSelf.inviteRequestsContext) { + if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: recommendedChannels ? .recommendedChannels : .generic, avatarInitiallyExpanded: expandAvatar, fromChat: true, requestsContext: strongSelf.inviteRequestsContext) { strongSelf.effectiveNavigationController?.pushViewController(infoController) } } @@ -12736,7 +12736,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G openBotApp(allowWrite, false) }, showMore: { [weak self] in if let self { - self.openResolved(result: .peer(botPeer._asPeer(), .info), sourceMessageId: nil) + self.openResolved(result: .peer(botPeer._asPeer(), .info(nil)), sourceMessageId: nil) } }) self.present(controller, in: .window(.root)) @@ -16343,8 +16343,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let _ = self.presentVoiceMessageDiscardAlert(action: { if case let .peer(currentPeerId) = self.chatLocation, peer?.id == currentPeerId { switch navigation { - case .info: - self.navigationButtonAction(.openChatInfo(expandAvatar: expandAvatar)) + case let .info(params): + var recommendedChannels = false + if let params, params.switchToRecommendedChannels { + recommendedChannels = true + } + self.navigationButtonAction(.openChatInfo(expandAvatar: expandAvatar, recommendedChannels: recommendedChannels)) case let .chat(textInputState, _, _): if let textInputState = textInputState { self.updateChatPresentationInterfaceState(animated: true, interactive: true, { @@ -16393,6 +16397,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let fromReactionMessageId = fromReactionMessageId { mode = .reaction(fromReactionMessageId) } + if case let .info(params) = navigation, let params, params.switchToRecommendedChannels { + mode = .recommendedChannels + } var expandAvatar = expandAvatar if peer.smallProfileImage == nil { expandAvatar = false diff --git a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift index 320fa27d16..9844a5678f 100644 --- a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift @@ -920,7 +920,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode { let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).startStandalone(next: { peer in if let peer = peer { - controllerInteraction.openPeer(peer, .info, nil, .default) + controllerInteraction.openPeer(peer, .info(nil), nil, .default) } }) case let .openWebView(url, simple): diff --git a/submodules/TelegramUI/Sources/OpenChatMessage.swift b/submodules/TelegramUI/Sources/OpenChatMessage.swift index ea1bffe859..fb5028708a 100644 --- a/submodules/TelegramUI/Sources/OpenChatMessage.swift +++ b/submodules/TelegramUI/Sources/OpenChatMessage.swift @@ -173,7 +173,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool { }, stopLiveLocation: { messageId in params.context.liveLocationManager?.cancelLiveLocation(peerId: messageId?.peerId ?? params.message.id.peerId) }, openUrl: params.openUrl, openPeer: { peer in - params.openPeer(peer._asPeer(), .info) + params.openPeer(peer._asPeer(), .info(nil)) }, showAll: params.modal) let controller = LocationViewController(context: params.context, updatedPresentationData: params.updatedPresentationData, subject: EngineMessage(params.message), params: controllerParams) controller.navigationPresentation = .modal diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index a00fc651f0..cba989a338 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -41,7 +41,7 @@ private func defaultNavigationForPeerId(_ peerId: PeerId?, navigation: ChatContr return .chat(textInputState: nil, subject: nil, peekData: nil) } } else { - return .info + return .info(nil) } } else { return navigation diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 85e0bf67fb..8c463d0c2a 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -1899,18 +1899,22 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation return PeerInfoScreenImpl(context: context, updatedPresentationData: updatedPresentationData, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, isOpenedFromChat: isOpenedFromChat, nearbyPeerDistance: nil, reactionSourceMessageId: nil, callMessages: []) } else if let _ = peer as? TelegramChannel { var forumTopicThread: ChatReplyThreadMessage? + var switchToRecommendedChannels = false switch mode { case let .forumTopic(thread): forumTopicThread = thread + case .recommendedChannels: + switchToRecommendedChannels = true default: break } - return PeerInfoScreenImpl(context: context, updatedPresentationData: updatedPresentationData, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, isOpenedFromChat: isOpenedFromChat, nearbyPeerDistance: nil, reactionSourceMessageId: nil, callMessages: [], forumTopicThread: forumTopicThread) + return PeerInfoScreenImpl(context: context, updatedPresentationData: updatedPresentationData, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, isOpenedFromChat: isOpenedFromChat, nearbyPeerDistance: nil, reactionSourceMessageId: nil, callMessages: [], forumTopicThread: forumTopicThread, switchToRecommendedChannels: switchToRecommendedChannels) } else if peer is TelegramUser { var nearbyPeerDistance: Int32? var reactionSourceMessageId: MessageId? var callMessages: [Message] = [] var hintGroupInCommon: PeerId? + switch mode { case let .nearbyPeer(distance): nearbyPeerDistance = distance @@ -1924,6 +1928,8 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation reactionSourceMessageId = messageId case .forumTopic: break + default: + break } return PeerInfoScreenImpl(context: context, updatedPresentationData: updatedPresentationData, peerId: peer.id, avatarInitiallyExpanded: avatarInitiallyExpanded, isOpenedFromChat: isOpenedFromChat, nearbyPeerDistance: nearbyPeerDistance, reactionSourceMessageId: reactionSourceMessageId, callMessages: callMessages, hintGroupInCommon: hintGroupInCommon) } else if peer is TelegramSecretChat { diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index c6660b3b37..385210f53d 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -620,7 +620,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) return .single(.result(.peer(peer, .chat(textInputState: nil, subject: nil, peekData: nil)))) } } else { - return .single(.result(.peer(nil, .info))) + return .single(.result(.peer(nil, .info(nil)))) } } case let .peer(reference, parameter): @@ -780,7 +780,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) return .single(.result(.peer(peer._asPeer(), .chat(textInputState: nil, subject: nil, peekData: nil)))) } } else { - return .single(.result(.peer(nil, .info))) + return .single(.result(.peer(nil, .info(nil)))) } } case let .peerId(peerId): @@ -796,9 +796,9 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) return .single(.progress) |> then(context.engine.peers.importContactToken(token: token) |> mapToSignal { peer -> Signal in if let peer = peer { - return .single(.result(.peer(peer._asPeer(), .info))) + return .single(.result(.peer(peer._asPeer(), .info(nil)))) } else { - return .single(.result(.peer(nil, .info))) + return .single(.result(.peer(nil, .info(nil)))) } }) case let .privateMessage(messageId, threadId, timecode):