Fix pinned title panel with managing bots

Fix #2181
This commit is contained in:
marks0kolov 2026-06-26 20:04:24 -07:00
parent 6e370e06d1
commit b241b1c3de

View file

@ -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)?
@ -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)?