diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index 875857ad41..2757bedab7 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -938,6 +938,7 @@ public protocol ChatController: ViewController { var purposefulAction: (() -> Void)? { get set } var stateUpdated: ((ContainedViewLayoutTransition) -> Void)? { get set } + var customDismissSearch: (() -> Void)? { get set } var selectedMessageIds: Set? { get } var presentationInterfaceStateSignal: Signal { get } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift index 80df1b1ffd..774183093f 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoChatListPaneNode/Sources/PeerInfoChatListPaneNode.swift @@ -409,6 +409,17 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, UI return } + chatController.customDismissSearch = { [weak self] in + guard let self else { + return + } + if self.searchNavigationContentNode !== nil { + self.searchNavigationContentNode = nil + self.externalDataUpdated?(.animated(duration: 0.4, curve: .spring)) + } + + self.removeChatController() + } chatController.stateUpdated = { [weak self] transition in guard let self, let chatController = self.chatController else { return diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index a77fc2c0dc..8d29d211e8 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -517,6 +517,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G public var customNavigationPanelNode: ChatControllerCustomNavigationPanelNode? public var stateUpdated: ((ContainedViewLayoutTransition) -> Void)? + public var customDismissSearch: (() -> Void)? + public override var customData: Any? { return self.chatLocation } @@ -9091,13 +9093,20 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.updateItemNodesSearchTextHighlightStates() }) }, dismissMessageSearch: { [weak self] in - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in - return current.updatedSearch(nil).updatedHistoryFilter(nil) - }) - strongSelf.updateItemNodesSearchTextHighlightStates() - strongSelf.searchResultsController = nil + guard let self else { + return } + + if let customDismissSearch = self.customDismissSearch { + customDismissSearch() + return + } + + self.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in + return current.updatedSearch(nil).updatedHistoryFilter(nil) + }) + self.updateItemNodesSearchTextHighlightStates() + self.searchResultsController = nil }, updateMessageSearch: { [weak self] query in if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { current in diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 6e98425032..e9a8014551 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -2475,8 +2475,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { mappedContents = .search(query: self.chatPresentationInterfaceState.search?.query ?? "", includeSavedPeers: self.alwaysShowSearchResultsAsList) } else if let historyFilter = self.chatPresentationInterfaceState.historyFilter { mappedContents = .tag(historyFilter.customTag) - } else if let search = self.chatPresentationInterfaceState.search, !search.query.isEmpty, self.alwaysShowSearchResultsAsList { - mappedContents = .search(query: search.query, includeSavedPeers: self.alwaysShowSearchResultsAsList) + } else if let search = self.chatPresentationInterfaceState.search, self.alwaysShowSearchResultsAsList { + if !search.query.isEmpty { + mappedContents = .search(query: search.query, includeSavedPeers: self.alwaysShowSearchResultsAsList) + } else { + mappedContents = .empty + } } else if case .peer(self.context.account.peerId) = self.chatPresentationInterfaceState.chatLocation { mappedContents = .tag(MemoryBuffer()) } else {