Skip to content

Commit 416a4ae

Browse files
committed
[trello.com/c/aZtAfZ44] fix select row when we enter the chat via popup
1 parent 77164d9 commit 416a4ae

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

Adamant/Modules/ChatsList/ChatListViewController.swift

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ extension ChatListViewController {
980980

981981
@MainActor
982982
func presentChatroom(_ chatroom: Chatroom, with message: String? = nil) {
983+
defer { updateSelectedRow(chatroom: chatroom) }
983984
// MARK: 1. Create and config ViewController
984985
let vc = chatViewController(for: chatroom, with: message)
985986

@@ -1602,14 +1603,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16021603
return
16031604
}
16041605

1605-
if let indexPath = tableView.indexPathForSelectedRow {
1606-
tableView.deselectRow(at: indexPath, animated: true)
1607-
}
1608-
1609-
if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) {
1610-
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1611-
}
1612-
16131606
presenter.presentChatroom(chatroom, with: message.transactionId)
16141607
}
16151608
}
@@ -1620,14 +1613,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16201613
return
16211614
}
16221615

1623-
if let indexPath = tableView.indexPathForSelectedRow {
1624-
tableView.deselectRow(at: indexPath, animated: true)
1625-
}
1626-
1627-
if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) {
1628-
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1629-
}
1630-
16311616
presenter.presentChatroom(chatroom)
16321617
}
16331618
}
@@ -1636,6 +1621,15 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16361621
account.chatroom?.isForcedVisible = true
16371622
newChatController(didSelectAccount: account, preMessage: nil, name: nil)
16381623
}
1624+
1625+
func updateSelectedRow(chatroom: Chatroom) {
1626+
if let indexPath = tableView.indexPathForSelectedRow {
1627+
tableView.deselectRow(at: indexPath, animated: true)
1628+
}
1629+
if let indexPath = self.chatsController?.indexPath(forObject: chatroom) {
1630+
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1631+
}
1632+
}
16391633
}
16401634

16411635
// MARK: Mac OS HotKeys

0 commit comments

Comments
 (0)