Skip to content

[trello.com/c/aZtAfZ44] fix select row when we enter the chat via popup #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions Adamant/Modules/ChatsList/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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)
}
}
Expand All @@ -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
Expand Down