mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
pass enabled accounts to wallet manager
This commit is contained in:
parent
fbe1396c9f
commit
4f2c55bddc
@ -197,7 +197,11 @@ final class WalletsManager {
|
||||
}
|
||||
}
|
||||
|
||||
func update(wallet: TokenaryWallet, coinDerivations: [CoinDerivation]) throws {
|
||||
func update(wallet: TokenaryWallet, enabledAccounts: [Account]) throws {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
func deprecatedupdate(wallet: TokenaryWallet, coinDerivations: [CoinDerivation]) throws {
|
||||
guard let password = keychain.password else { throw Error.keychainAccessFailure }
|
||||
|
||||
for account in wallet.accounts {
|
||||
|
@ -20,6 +20,7 @@ class EditAccountsViewController: NSViewController {
|
||||
private var page = 1
|
||||
private var requestedPreviewFor: Int?
|
||||
private var lastPreviewDate = Date()
|
||||
private var toggledIndexes = Set<Int>()
|
||||
|
||||
@IBOutlet weak var tableView: RightClickTableView! {
|
||||
didSet {
|
||||
@ -43,24 +44,18 @@ class EditAccountsViewController: NSViewController {
|
||||
}
|
||||
|
||||
@IBAction func okButtonTapped(_ sender: Any) {
|
||||
let newAccounts: [Account] = cellModels.compactMap { model in
|
||||
if model.isEnabled {
|
||||
return model.account
|
||||
} else {
|
||||
return nil
|
||||
guard !toggledIndexes.isEmpty else {
|
||||
showAccountsList()
|
||||
return
|
||||
}
|
||||
}
|
||||
let accountsChanged = false // TODO: implement
|
||||
if accountsChanged {
|
||||
|
||||
let newAccounts: [Account] = cellModels.compactMap { $0.isEnabled ? $0.account : nil }
|
||||
do {
|
||||
// TODO: update accounts
|
||||
try walletsManager.update(wallet: wallet, enabledAccounts: newAccounts)
|
||||
showAccountsList()
|
||||
} catch {
|
||||
Alert.showWithMessage(Strings.somethingWentWrong, style: .informational)
|
||||
}
|
||||
} else {
|
||||
showAccountsList()
|
||||
}
|
||||
}
|
||||
|
||||
private func showAccountsList() {
|
||||
@ -73,6 +68,11 @@ class EditAccountsViewController: NSViewController {
|
||||
private func toggleCoinDerivation(row: Int) {
|
||||
cellModels[row].isEnabled.toggle()
|
||||
okButton.isEnabled = cellModels.contains(where: { $0.isEnabled })
|
||||
if toggledIndexes.contains(row) {
|
||||
toggledIndexes.remove(row)
|
||||
} else {
|
||||
toggledIndexes.insert(row)
|
||||
}
|
||||
}
|
||||
|
||||
private func previewMoreAccountsIfNeeded() {
|
||||
|
Loading…
Reference in New Issue
Block a user