Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 57 additions & 9 deletions submodules/TelegramUI/Sources/ChatControllerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,25 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
return adPanelView.message?._asMessage()
}

private var shouldDisplayPinnedTitlePanel: Bool {
guard self.chatPresentationInterfaceState.titlePanelContexts.contains(.pinnedMessage) else {
return false
}
guard let pinnedMessage = self.chatPresentationInterfaceState.pinnedMessage else {
return false
}
if pinnedMessage.topMessageId == self.chatPresentationInterfaceState.interfaceState.messageActionsState.closedPinnedMessageId {
return false
}
if self.chatPresentationInterfaceState.pendingUnpinnedAllMessages {
return false
}
return true
}

private let titleAccessoryPanelContainer: ChatControllerTitlePanelNodeContainer
private var currentTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode?
private var currentPinnedTitleAccessoryPanelNode: ChatPinnedMessageTitlePanelNode?

private var floatingTopicsPanelContainer: ChatControllerTitlePanelNodeContainer
private var floatingTopicsPanel: (view: ComponentView<ChatSidePanelEnvironment>, component: ChatFloatingTopicsPanel)?
Expand Down Expand Up @@ -1564,17 +1581,48 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {

if let titleAccessoryPanelNode = titlePanelForChatPresentationInterfaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.currentTitleAccessoryPanelNode, controllerInteraction: self.controllerInteraction, interfaceInteraction: self.interfaceInteraction, force: false) {
self.currentTitleAccessoryPanelNode = titleAccessoryPanelNode
let panelKey = "\(type(of: titleAccessoryPanelNode))"
headerPanels.append(HeaderPanelContainerComponent.Panel(
key: panelKey,
orderIndex: 3,
component: AnyComponent(LegacyChatHeaderPanelComponent(
panelNode: titleAccessoryPanelNode,
interfaceState: self.chatPresentationInterfaceState
)))
)
if titleAccessoryPanelNode is ChatManagingBotTitlePanelNode, self.shouldDisplayPinnedTitlePanel {
let pinnedPanelNode: ChatPinnedMessageTitlePanelNode
if let current = self.currentPinnedTitleAccessoryPanelNode {
pinnedPanelNode = current
} else {
pinnedPanelNode = ChatPinnedMessageTitlePanelNode(context: self.context, animationCache: self.controllerInteraction.presentationContext.animationCache, animationRenderer: self.controllerInteraction.presentationContext.animationRenderer)
pinnedPanelNode.interfaceInteraction = self.interfaceInteraction
self.currentPinnedTitleAccessoryPanelNode = pinnedPanelNode
}

headerPanels.append(HeaderPanelContainerComponent.Panel(
key: "\(ChatPinnedMessageTitlePanelNode.self)",
orderIndex: 3,
component: AnyComponent(LegacyChatHeaderPanelComponent(
panelNode: pinnedPanelNode,
interfaceState: self.chatPresentationInterfaceState
)))
)
headerPanels.append(HeaderPanelContainerComponent.Panel(
key: "\(type(of: titleAccessoryPanelNode))",
orderIndex: 4,
component: AnyComponent(LegacyChatHeaderPanelComponent(
panelNode: titleAccessoryPanelNode,
interfaceState: self.chatPresentationInterfaceState
)))
)
} else {
self.currentPinnedTitleAccessoryPanelNode = nil

let panelKey = "\(type(of: titleAccessoryPanelNode))"
headerPanels.append(HeaderPanelContainerComponent.Panel(
key: panelKey,
orderIndex: 3,
component: AnyComponent(LegacyChatHeaderPanelComponent(
panelNode: titleAccessoryPanelNode,
interfaceState: self.chatPresentationInterfaceState
)))
)
}
} else {
self.currentTitleAccessoryPanelNode = nil
self.currentPinnedTitleAccessoryPanelNode = nil
}

var displayFeePanel: (value: Int64, peer: EnginePeer)?
Expand Down