From e4bb16bd53012f033fd15c1537c4733aa05e8a23 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 30 Dec 2025 21:46:18 +0800 Subject: [PATCH] Fix peer selection controller --- .../Sources/PeerSelectionController.swift | 7 +++++-- .../Sources/PeerSelectionControllerNode.swift | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionController.swift b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionController.swift index f7025abfbb..d5361bc583 100644 --- a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionController.swift +++ b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionController.swift @@ -150,7 +150,6 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon if params.forumPeerId == nil { self.navigationPresentation = .modal - self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed)) } self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil) @@ -257,6 +256,8 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon } override public func loadDisplayNode() { + self.navigationBar?.secondaryContentHeight = 44.0 + 10.0 + self.displayNode = PeerSelectionControllerNode(context: self.context, controller: self, presentationData: self.presentationData, filter: self.filter, forumPeerId: self.forumPeerId, hasFilters: self.hasFilters, hasChatListSelector: self.hasChatListSelector, hasContactSelector: self.hasContactSelector, hasGlobalSearch: self.hasGlobalSearch, forwardedMessageIds: self.forwardedMessageIds, hasTypeHeaders: self.hasTypeHeaders, requestPeerType: self.requestPeerType, hasCreation: self.hasCreation, createNewGroup: self.createNewGroup, present: { [weak self] c, a in self?.present(c, in: .window(.root), with: a) }, presentInGlobalOverlay: { [weak self] c, a in @@ -463,6 +464,8 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon } private var initializedFilters = false + private(set) var chatListFiltersNonEmpty: Bool = false + private func reloadFilters(firstUpdate: (() -> Void)? = nil) { let filterItems = chatListFilterItems(context: self.context) var notifiedFirstUpdate = false @@ -566,8 +569,8 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon let isEmpty = resolvedItems.count <= 1 + strongSelf.chatListFiltersNonEmpty = !isEmpty if wasEmpty != isEmpty, strongSelf.displayNavigationBar { - strongSelf.navigationBar?.secondaryContentHeight = isEmpty ? 0.0 : (44.0 + 10.0) strongSelf.navigationBar?.setSecondaryContentNode(isEmpty ? nil : strongSelf.tabContainerNode, animated: false) } diff --git a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift index a677e4a73c..c3b08d85cd 100644 --- a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift @@ -1459,7 +1459,9 @@ final class PeerSelectionControllerNode: ASDisplayNode { self.chatListNode?.accessibilityElementsHidden = false self.mainContainerNode?.accessibilityElementsHidden = false - self.navigationBar?.setSecondaryContentNode(self.controller?.tabContainerNode, animated: true) + if let controller = self.controller, controller.chatListFiltersNonEmpty { + self.navigationBar?.setSecondaryContentNode(self.controller?.tabContainerNode, animated: true) + } self.controller?.setDisplayNavigationBar(true, transition: .animated(duration: 0.5, curve: .spring)) searchDisplayController.deactivate(placeholder: placeholderNode) @@ -1587,7 +1589,9 @@ final class PeerSelectionControllerNode: ASDisplayNode { } } } else if let contactListNode = self.contactListNode { - self.navigationBar?.setSecondaryContentNode(self.controller?.tabContainerNode, animated: false) + if let controller = self.controller, controller.chatListFiltersNonEmpty { + self.navigationBar?.setSecondaryContentNode(self.controller?.tabContainerNode, animated: false) + } contactListNode.enableUpdates = false if let mainContainerNode = self.mainContainerNode {