From 416a4ae8623e6ac07910e474d692cd8b611b7550 Mon Sep 17 00:00:00 2001 From: Vladimir Klevtsov Date: Fri, 23 May 2025 16:41:06 +0200 Subject: [PATCH] [trello.com/c/aZtAfZ44] fix select row when we enter the chat via popup --- .../ChatsList/ChatListViewController.swift | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Adamant/Modules/ChatsList/ChatListViewController.swift b/Adamant/Modules/ChatsList/ChatListViewController.swift index b578b321d..d67f0b1d3 100644 --- a/Adamant/Modules/ChatsList/ChatListViewController.swift +++ b/Adamant/Modules/ChatsList/ChatListViewController.swift @@ -980,6 +980,7 @@ extension ChatListViewController { @MainActor func presentChatroom(_ chatroom: Chatroom, with message: String? = nil) { + defer { updateSelectedRow(chatroom: chatroom) } // MARK: 1. Create and config ViewController let vc = chatViewController(for: chatroom, with: message) @@ -1602,14 +1603,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating, return } - if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRow(at: indexPath, animated: true) - } - - if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) { - tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) - } - presenter.presentChatroom(chatroom, with: message.transactionId) } } @@ -1620,14 +1613,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating, return } - if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRow(at: indexPath, animated: true) - } - - if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) { - tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) - } - presenter.presentChatroom(chatroom) } } @@ -1636,6 +1621,15 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating, account.chatroom?.isForcedVisible = true newChatController(didSelectAccount: account, preMessage: nil, name: nil) } + + func updateSelectedRow(chatroom: Chatroom) { + if let indexPath = tableView.indexPathForSelectedRow { + tableView.deselectRow(at: indexPath, animated: true) + } + if let indexPath = self.chatsController?.indexPath(forObject: chatroom) { + tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) + } + } } // MARK: Mac OS HotKeys