Remove account selection on removal

This commit is contained in:
Ivan Grachev 2022-08-24 20:30:24 +03:00
parent 546c41b018
commit e84b9e0c40

View File

@ -301,9 +301,23 @@ class AccountsListViewController: UIViewController, DataStateContainer {
}
@objc private func walletsChanged() {
validateSelectedAccounts()
updatePrimaryButton()
reloadData()
}
private func validateSelectedAccounts() {
guard let specificWalletAccounts = selectAccountAction?.selectedAccounts else { return }
for specificWalletAccount in specificWalletAccounts {
if let wallet = wallets.first(where: { $0.id == specificWalletAccount.walletId }),
wallet.accounts.contains(specificWalletAccount.account) {
continue
} else {
selectAccountAction?.selectedAccounts.remove(specificWalletAccount)
}
}
}
private func updateDataState() {
let isEmpty = sections.isEmpty
dataState = isEmpty ? .noData : .hasData