@@ -980,6 +980,7 @@ extension ChatListViewController {
980
980
981
981
@MainActor
982
982
func presentChatroom( _ chatroom: Chatroom , with message: String ? = nil ) {
983
+ defer { updateSelectedRow ( chatroom: chatroom) }
983
984
// MARK: 1. Create and config ViewController
984
985
let vc = chatViewController ( for: chatroom, with: message)
985
986
@@ -1602,14 +1603,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
1602
1603
return
1603
1604
}
1604
1605
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
-
1613
1606
presenter. presentChatroom ( chatroom, with: message. transactionId)
1614
1607
}
1615
1608
}
@@ -1620,14 +1613,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
1620
1613
return
1621
1614
}
1622
1615
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
-
1631
1616
presenter. presentChatroom ( chatroom)
1632
1617
}
1633
1618
}
@@ -1636,6 +1621,15 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
1636
1621
account. chatroom? . isForcedVisible = true
1637
1622
newChatController ( didSelectAccount: account, preMessage: nil , name: nil )
1638
1623
}
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
+ }
1639
1633
}
1640
1634
1641
1635
// MARK: Mac OS HotKeys
0 commit comments