From 0ca74747a5bc9856278337c26be5476ca9ae8e21 Mon Sep 17 00:00:00 2001 From: StanislavDevIOS Date: Mon, 12 Jun 2023 12:28:05 +0300 Subject: [PATCH] [trello.com/c/Q5t2dsq4] fix: update the wallet visibility status in the search mode --- .../VisibleWalletsTableViewCell.swift | 2 ++ .../VisibleWalletsViewController.swift | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsTableViewCell.swift b/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsTableViewCell.swift index 050899169..8603e3115 100644 --- a/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsTableViewCell.swift +++ b/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsTableViewCell.swift @@ -59,6 +59,8 @@ class VisibleWalletsTableViewCell: UITableViewCell { set { checkmarkRowView.balance = newValue } } + var unicId: String? + required override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setupView() diff --git a/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsViewController.swift b/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsViewController.swift index 341e3fe81..1248f1b67 100644 --- a/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsViewController.swift +++ b/Adamant/Stories/Settings/VisibleWallets/VisibleWalletsViewController.swift @@ -234,6 +234,7 @@ extension VisibleWalletsViewController: UITableViewDataSource, UITableViewDelega cell.balance = wallet.wallet?.balance cell.delegate = self cell.isChecked = !isInvisible(wallet) + cell.unicId = wallet.tokenUnicID return cell } @@ -292,11 +293,16 @@ extension VisibleWalletsViewController: UITableViewDataSource, UITableViewDelega // MARK: - AdamantVisibleWalletsCellDelegate extension VisibleWalletsViewController: AdamantVisibleWalletsCellDelegate { - func delegateCell(_ cell: VisibleWalletsTableViewCell, didChangeCheckedStateTo state: Bool) { - guard let indexPath = tableView.indexPath(for: cell) else { - return - } - let wallet = wallets[indexPath.row] + func delegateCell( + _ cell: VisibleWalletsTableViewCell, + didChangeCheckedStateTo state: Bool + ) { + let wallet = wallets.first(where: { + $0.tokenUnicID == cell.unicId + }) + + guard let wallet = wallet else { return } + if !isInvisible(wallet) { visibleWalletsService.addToInvisibleWallets(wallet) } else {