Skip to content

Commit d89a78d

Browse files
authored
Merge pull request #868 from Adamant-im/trello.com/c/aZtAfZ44
[trello.com/c/aZtAfZ44] fix select row when we enter the chat via popup
2 parents 365cac0 + 416a4ae commit d89a78d

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
@@ -1002,6 +1002,7 @@ extension ChatListViewController {
10021002

10031003
@MainActor
10041004
func presentChatroom(_ chatroom: Chatroom, with message: String? = nil) {
1005+
defer { updateSelectedRow(chatroom: chatroom) }
10051006
// MARK: 1. Create and config ViewController
10061007
let vc = chatViewController(for: chatroom, with: message)
10071008

@@ -1625,14 +1626,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16251626
return
16261627
}
16271628

1628-
if let indexPath = tableView.indexPathForSelectedRow {
1629-
tableView.deselectRow(at: indexPath, animated: true)
1630-
}
1631-
1632-
if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) {
1633-
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1634-
}
1635-
16361629
presenter.presentChatroom(chatroom, with: message.transactionId)
16371630
}
16381631
}
@@ -1643,14 +1636,6 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16431636
return
16441637
}
16451638

1646-
if let indexPath = tableView.indexPathForSelectedRow {
1647-
tableView.deselectRow(at: indexPath, animated: true)
1648-
}
1649-
1650-
if let indexPath = self?.chatsController?.indexPath(forObject: chatroom) {
1651-
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1652-
}
1653-
16541639
presenter.presentChatroom(chatroom)
16551640
}
16561641
}
@@ -1659,6 +1644,15 @@ extension ChatListViewController: UISearchBarDelegate, UISearchResultsUpdating,
16591644
account.chatroom?.isForcedVisible = true
16601645
newChatController(didSelectAccount: account, preMessage: nil, name: nil)
16611646
}
1647+
1648+
func updateSelectedRow(chatroom: Chatroom) {
1649+
if let indexPath = tableView.indexPathForSelectedRow {
1650+
tableView.deselectRow(at: indexPath, animated: true)
1651+
}
1652+
if let indexPath = self.chatsController?.indexPath(forObject: chatroom) {
1653+
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
1654+
}
1655+
}
16621656
}
16631657

16641658
// MARK: Mac OS HotKeys

0 commit comments

Comments
 (0)