fix(@wallet): Copy viewed account details (#14161)
This commit is contained in:
parent
e937dfb56c
commit
fae7e82e0a
|
@ -3,6 +3,8 @@ import NimQml, sequtils, strutils
|
||||||
import ./io_interface
|
import ./io_interface
|
||||||
import ./model
|
import ./model
|
||||||
import app/modules/shared_models/keypair_model
|
import app/modules/shared_models/keypair_model
|
||||||
|
import app/modules/shared_models/keypair_item
|
||||||
|
import app/modules/shared_models/keypair_account_item
|
||||||
import app/modules/shared_models/wallet_account_item
|
import app/modules/shared_models/wallet_account_item
|
||||||
import app/modules/shared_models/currency_amount
|
import app/modules/shared_models/currency_amount
|
||||||
|
|
||||||
|
@ -13,6 +15,8 @@ QtObject:
|
||||||
accounts: Model
|
accounts: Model
|
||||||
accountsVariant: QVariant
|
accountsVariant: QVariant
|
||||||
keyPairModel: KeyPairModel
|
keyPairModel: KeyPairModel
|
||||||
|
selectedKeyPair: KeyPairItem
|
||||||
|
selectedAccount: KeyPairAccountItem
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.accounts.delete
|
self.accounts.delete
|
||||||
|
@ -28,6 +32,40 @@ QtObject:
|
||||||
result.accountsVariant = newQVariant(result.accounts)
|
result.accountsVariant = newQVariant(result.accounts)
|
||||||
result.keyPairModel = newKeyPairModel()
|
result.keyPairModel = newKeyPairModel()
|
||||||
|
|
||||||
|
proc getSelectedKeyPair*(self: View): QVariant {.slot.} =
|
||||||
|
if self.selectedKeyPair.isNil:
|
||||||
|
return newQVariant()
|
||||||
|
return newQVariant(self.selectedKeyPair)
|
||||||
|
|
||||||
|
proc selectedKeyPairChanged(self: View) {.signal.}
|
||||||
|
|
||||||
|
QtProperty[QVariant] selectedKeyPair:
|
||||||
|
read = getSelectedKeyPair
|
||||||
|
notify = selectedKeyPairChanged
|
||||||
|
|
||||||
|
proc getSelectedAccount*(self: View): QVariant {.slot.} =
|
||||||
|
if self.selectedAccount.isNil:
|
||||||
|
return newQVariant()
|
||||||
|
return newQVariant(self.selectedAccount)
|
||||||
|
|
||||||
|
proc selectedAccountChanged(self: View) {.signal.}
|
||||||
|
|
||||||
|
QtProperty[QVariant] selectedAccount:
|
||||||
|
read = getSelectedAccount
|
||||||
|
notify = selectedAccountChanged
|
||||||
|
|
||||||
|
proc setSelectedAccount*(self: View, address: string) {.slot.} =
|
||||||
|
let (selectedKeyPair, selectedAccount) = self.keyPairModel.findKeyPairAndAccountByAddresss(address)
|
||||||
|
self.selectedKeyPair = selectedKeyPair
|
||||||
|
self.selectedAccount = selectedAccount
|
||||||
|
self.selectedKeyPairChanged()
|
||||||
|
self.selectedAccountChanged()
|
||||||
|
|
||||||
|
proc refreshSelectedAccount(self: View) =
|
||||||
|
if self.selectedAccount.isNil:
|
||||||
|
return
|
||||||
|
self.setSelectedAccount(self.selectedAccount.getAddress())
|
||||||
|
|
||||||
proc load*(self: View) =
|
proc load*(self: View) =
|
||||||
self.delegate.viewDidLoad()
|
self.delegate.viewDidLoad()
|
||||||
|
|
||||||
|
@ -49,15 +87,19 @@ QtObject:
|
||||||
proc onUpdatedAccount*(self: View, account: WalletAccountItem) =
|
proc onUpdatedAccount*(self: View, account: WalletAccountItem) =
|
||||||
self.accounts.onUpdatedAccount(account)
|
self.accounts.onUpdatedAccount(account)
|
||||||
self.keyPairModel.onUpdatedAccount(account.keyUid, account.address, account.name, account.colorId, account.emoji)
|
self.keyPairModel.onUpdatedAccount(account.keyUid, account.address, account.name, account.colorId, account.emoji)
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc onUpdatedKeypairOperability*(self: View, keyUid, operability: string) =
|
proc onUpdatedKeypairOperability*(self: View, keyUid, operability: string) =
|
||||||
self.keyPairModel.onUpdatedKeypairOperability(keyUid, operability)
|
self.keyPairModel.onUpdatedKeypairOperability(keyUid, operability)
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
|
proc onPreferredSharingChainsUpdated*(self: View, keyUid, address, prodPreferredChainIds, testPreferredChainIds: string) =
|
||||||
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
|
self.keyPairModel.onPreferredSharingChainsUpdated(keyUid, address, prodPreferredChainIds, testPreferredChainIds)
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc onHideFromTotalBalanceUpdated*(self: View, keyUid, address: string, hideFromTotalBalance: bool) =
|
proc onHideFromTotalBalanceUpdated*(self: View, keyUid, address: string, hideFromTotalBalance: bool) =
|
||||||
self.keyPairModel.onHideFromTotalBalanceUpdated(keyUid, address, hideFromTotalBalance)
|
self.keyPairModel.onHideFromTotalBalanceUpdated(keyUid, address, hideFromTotalBalance)
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc deleteAccount*(self: View, address: string) {.slot.} =
|
proc deleteAccount*(self: View, address: string) {.slot.} =
|
||||||
self.delegate.deleteAccount(address)
|
self.delegate.deleteAccount(address)
|
||||||
|
@ -78,6 +120,7 @@ QtObject:
|
||||||
proc setKeyPairModelItems*(self: View, items: seq[KeyPairItem]) =
|
proc setKeyPairModelItems*(self: View, items: seq[KeyPairItem]) =
|
||||||
self.keyPairModel.setItems(items)
|
self.keyPairModel.setItems(items)
|
||||||
self.keyPairModelChanged()
|
self.keyPairModelChanged()
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc keypairNameExists*(self: View, name: string): bool {.slot.} =
|
proc keypairNameExists*(self: View, name: string): bool {.slot.} =
|
||||||
return self.keyPairModel.keypairNameExists(name)
|
return self.keyPairModel.keypairNameExists(name)
|
||||||
|
@ -99,6 +142,7 @@ QtObject:
|
||||||
|
|
||||||
proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) =
|
proc setBalanceForKeyPairs*(self: View, address: string, balance: CurrencyAmount) =
|
||||||
self.keyPairModel.setBalanceForAddress(address, balance)
|
self.keyPairModel.setBalanceForAddress(address, balance)
|
||||||
|
self.refreshSelectedAccount()
|
||||||
|
|
||||||
proc updateWatchAccountHiddenFromTotalBalance*(self: View, address: string, hideFromTotalBalance: bool) {.slot.} =
|
proc updateWatchAccountHiddenFromTotalBalance*(self: View, address: string, hideFromTotalBalance: bool) {.slot.} =
|
||||||
self.delegate.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
|
self.delegate.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
|
||||||
|
|
|
@ -98,6 +98,12 @@ QtObject:
|
||||||
return newKeyPairAccountItem()
|
return newKeyPairAccountItem()
|
||||||
return self.items[index]
|
return self.items[index]
|
||||||
|
|
||||||
|
proc getItemByAddress*(self: KeyPairAccountModel, address: string): KeyPairAccountItem =
|
||||||
|
for it in self.items:
|
||||||
|
if cmpIgnoreCase(it.getAddress(), address) == 0:
|
||||||
|
return it
|
||||||
|
return nil
|
||||||
|
|
||||||
proc removeItemAtIndex*(self: KeyPairAccountModel, index: int) =
|
proc removeItemAtIndex*(self: KeyPairAccountModel, index: int) =
|
||||||
if (index < 0 or index >= self.items.len):
|
if (index < 0 or index >= self.items.len):
|
||||||
return
|
return
|
||||||
|
|
|
@ -96,6 +96,9 @@ QtObject:
|
||||||
accounts: {$self.accounts},
|
accounts: {$self.accounts},
|
||||||
]"""
|
]"""
|
||||||
|
|
||||||
|
proc getAccountByAddress*(self: KeyPairItem, address: string): KeyPairAccountItem =
|
||||||
|
return self.accounts.getItemByAddress(address)
|
||||||
|
|
||||||
proc keyUidChanged*(self: KeyPairItem) {.signal.}
|
proc keyUidChanged*(self: KeyPairItem) {.signal.}
|
||||||
proc getKeyUid*(self: KeyPairItem): string {.slot.} =
|
proc getKeyUid*(self: KeyPairItem): string {.slot.} =
|
||||||
return self.keyUid
|
return self.keyUid
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import NimQml, Tables, stew/shims/strformat, sequtils, sugar
|
import NimQml, Tables, stew/shims/strformat, sequtils, sugar
|
||||||
import keypair_item
|
import keypair_item
|
||||||
|
import keypair_account_item
|
||||||
import ./currency_amount
|
import ./currency_amount
|
||||||
|
|
||||||
export keypair_item
|
export keypair_item
|
||||||
|
@ -76,6 +77,13 @@ QtObject:
|
||||||
return self.items[i]
|
return self.items[i]
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
|
proc findKeyPairAndAccountByAddresss*(self: KeyPairModel, address: string): (KeyPairItem, KeyPairAccountItem) =
|
||||||
|
for i in 0 ..< self.items.len:
|
||||||
|
let account = self.items[i].getAccountByAddress(address)
|
||||||
|
if not account.isNil:
|
||||||
|
return (self.items[i], account)
|
||||||
|
return (nil, nil)
|
||||||
|
|
||||||
proc onUpdatedAccount*(self: KeyPairModel, keyUid, address, name, colorId, emoji: string) =
|
proc onUpdatedAccount*(self: KeyPairModel, keyUid, address, name, colorId, emoji: string) =
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
if keyUid == item.getKeyUid():
|
if keyUid == item.getKeyUid():
|
||||||
|
|
|
@ -71,6 +71,10 @@ QtObject {
|
||||||
root.accountsModule.moveAccountFinally(from, to)
|
root.accountsModule.moveAccountFinally(from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSelectedAccount(address) {
|
||||||
|
root.accountsModule.setSelectedAccount(address)
|
||||||
|
}
|
||||||
|
|
||||||
function getAllNetworksChainIds() {
|
function getAllNetworksChainIds() {
|
||||||
return networksModule.getAllNetworksChainIds()
|
return networksModule.getAllNetworksChainIds()
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,8 +204,10 @@ SettingsContentBase {
|
||||||
if (!!account && !!account.address) {
|
if (!!account && !!account.address) {
|
||||||
root.rootStore.addressWasShown(account.address)
|
root.rootStore.addressWasShown(account.address)
|
||||||
}
|
}
|
||||||
root.walletStore.selectedAccount = account
|
|
||||||
accountView.keyPair = keypair
|
root.walletStore.setSelectedAccount(account.address)
|
||||||
|
root.walletStore.selectedAccount = Qt.binding(function() { return root.walletStore.accountsModule.selectedAccount })
|
||||||
|
accountView.keyPair = Qt.binding(function() { return root.walletStore.accountsModule.selectedKeyPair })
|
||||||
stackContainer.currentIndex = accountViewIndex
|
stackContainer.currentIndex = accountViewIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +288,12 @@ SettingsContentBase {
|
||||||
emojiPopup: root.emojiPopup
|
emojiPopup: root.emojiPopup
|
||||||
userProfilePublicKey: walletStore.userProfilePublicKey
|
userProfilePublicKey: walletStore.userProfilePublicKey
|
||||||
onGoBack: stackContainer.currentIndex = mainViewIndex
|
onGoBack: stackContainer.currentIndex = mainViewIndex
|
||||||
onVisibleChanged: if(!visible) root.walletStore.selectedAccount = null
|
onVisibleChanged: {
|
||||||
|
if (!visible) {
|
||||||
|
root.walletStore.selectedAccount = null
|
||||||
|
keyPair = null
|
||||||
|
}
|
||||||
|
}
|
||||||
onRunRenameKeypairFlow: {
|
onRunRenameKeypairFlow: {
|
||||||
renameKeypairPopup.keyUid = keyPair.keyUid
|
renameKeypairPopup.keyUid = keyPair.keyUid
|
||||||
renameKeypairPopup.name = keyPair.name
|
renameKeypairPopup.name = keyPair.name
|
||||||
|
|
|
@ -23,7 +23,7 @@ Column {
|
||||||
|
|
||||||
signal goToNetworksView()
|
signal goToNetworksView()
|
||||||
signal goToAccountOrderView()
|
signal goToAccountOrderView()
|
||||||
signal goToAccountView(var account, var keypair)
|
signal goToAccountView(var account)
|
||||||
signal goToDappPermissionsView()
|
signal goToDappPermissionsView()
|
||||||
signal goToManageTokensView()
|
signal goToManageTokensView()
|
||||||
signal goToSavedAddressesView()
|
signal goToSavedAddressesView()
|
||||||
|
@ -267,7 +267,7 @@ Column {
|
||||||
hasPairedDevices: root.walletStore.walletModule.hasPairedDevices
|
hasPairedDevices: root.walletStore.walletModule.hasPairedDevices
|
||||||
getNetworkShortNames: walletStore.getNetworkShortNames
|
getNetworkShortNames: walletStore.getNetworkShortNames
|
||||||
userProfilePublicKey: walletStore.userProfilePublicKey
|
userProfilePublicKey: walletStore.userProfilePublicKey
|
||||||
onGoToAccountView: root.goToAccountView(account, keyPair)
|
onGoToAccountView: root.goToAccountView(account)
|
||||||
onRunRenameKeypairFlow: root.runRenameKeypairFlow(model)
|
onRunRenameKeypairFlow: root.runRenameKeypairFlow(model)
|
||||||
onRunRemoveKeypairFlow: root.runRemoveKeypairFlow(model)
|
onRunRemoveKeypairFlow: root.runRemoveKeypairFlow(model)
|
||||||
onRunImportViaSeedPhraseFlow: {
|
onRunImportViaSeedPhraseFlow: {
|
||||||
|
|
Loading…
Reference in New Issue