fix(@desktop/wallet): updated ui for removed wallet accounts which are still on a keycard
This commit is contained in:
parent
5122815df8
commit
d830624d85
|
@ -3,3 +3,4 @@
|
|||
const LOGIN_ACCOUNTS_LIST_ADD_NEW_USER* = "LOGIN-ACCOUNTS-LIST-ADD-NEW-USER"
|
||||
const LOGIN_ACCOUNTS_LIST_ADD_EXISTING_USER* = "LOGIN-ACCOUNTS-LIST-ADD-EXISTING-USER"
|
||||
const LOGIN_ACCOUNTS_LIST_LOST_KEYCARD* = "LOGIN-ACCOUNTS-LIST-LOST-KEYCARD"
|
||||
const KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT* = "KEYCARD-ACCOUNT-NAME-OF-UNKNOWN-WALLET-ACCOUNT"
|
|
@ -3,6 +3,7 @@ import NimQml, chronicles, json, marshal, sequtils, sugar, strutils
|
|||
import ./io_interface, ./view, ./controller
|
||||
import ../io_interface as delegate_interface
|
||||
|
||||
import ../../../../global/app_translatable_constants as atc
|
||||
import ../../../../global/global_singleton
|
||||
import ../../../../core/eventemitter
|
||||
|
||||
|
@ -252,7 +253,7 @@ proc buildKeycardItem(self: Module, walletAccounts: seq[WalletAccountDto], keyPa
|
|||
var i = 0
|
||||
for ua in unknownAccountsAddresses:
|
||||
i.inc
|
||||
let name = "acc" & $i
|
||||
let name = atc.KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT & $i
|
||||
item.addAccount(newKeyPairAccountItem(name, path = "", ua, pubKey = "", emoji = "", color = "#939BA1", icon = "wallet", balance = 0.0))
|
||||
return item
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import view, controller
|
|||
import internal/[state, state_factory]
|
||||
import ../../shared/keypairs
|
||||
import ../../shared_models/[keypair_model, keypair_item]
|
||||
import ../../../global/app_translatable_constants as atc
|
||||
import ../../../global/global_singleton
|
||||
import ../../../core/eventemitter
|
||||
|
||||
|
@ -534,12 +535,6 @@ method setSelectedKeyPair*[T](self: Module[T], item: KeyPairItem) =
|
|||
paths, keyPairDto)
|
||||
self.setKeyPairForProcessing(item)
|
||||
|
||||
proc generateRandomColor[T](self: Module[T]): string =
|
||||
let r = rand(0 .. 255)
|
||||
let g = rand(0 .. 255)
|
||||
let b = rand(0 .. 255)
|
||||
return "#" & r.toHex(2) & g.toHex(2) & b.toHex(2)
|
||||
|
||||
proc updateKeyPairItemIfDataAreKnown[T](self: Module[T], address: string, item: var KeyPairItem): bool =
|
||||
let accounts = self.controller.getWalletAccounts()
|
||||
for a in accounts:
|
||||
|
@ -575,13 +570,16 @@ proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardM
|
|||
result.item.setKeyUid(currKp.getKeyUid())
|
||||
result.item.setPubKey(currKp.getPubKey())
|
||||
result.knownKeyPair = true
|
||||
var unknonwAccountNumber = 0
|
||||
for wa in cardMetadata.walletAccounts:
|
||||
if self.updateKeyPairItemIfDataAreKnown(wa.address, result.item):
|
||||
continue
|
||||
let (balance, balanceFetched) = self.controller.getOrFetchBalanceForAddressInPreferredCurrency(wa.address)
|
||||
result.knownKeyPair = false
|
||||
result.item.addAccount(newKeyPairAccountItem(name = "", wa.path, wa.address, pubKey = wa.publicKey, emoji = "",
|
||||
color = self.generateRandomColor(), icon = "wallet", balance, balanceFetched))
|
||||
unknonwAccountNumber.inc
|
||||
let name = atc.KEYCARD_ACCOUNT_NAME_OF_UNKNOWN_WALLET_ACCOUNT & $unknonwAccountNumber
|
||||
result.item.addAccount(newKeyPairAccountItem(name, wa.path, wa.address, pubKey = wa.publicKey, emoji = "",
|
||||
color = "#939BA1", icon = "wallet", balance, balanceFetched))
|
||||
|
||||
method updateKeyPairForProcessing*[T](self: Module[T], cardMetadata: CardMetadata) =
|
||||
let(item, knownKeyPair) = self.buildKeyPairItemBasedOnCardMetadata(cardMetadata)
|
||||
|
|
|
@ -90,7 +90,7 @@ StatusListItem {
|
|||
width: 16
|
||||
height: 16
|
||||
}
|
||||
title: model.account.name
|
||||
title: Utils.appTranslation(model.account.name)
|
||||
titleText.font.pixelSize: 12
|
||||
titleText.color: Theme.palette.indirectColor1
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ StatusListItem {
|
|||
width: 16
|
||||
height: 16
|
||||
}
|
||||
title: model.account.name
|
||||
title: Utils.appTranslation(model.account.name)
|
||||
titleText.font.pixelSize: 12
|
||||
titleText.color: Theme.palette.indirectColor1
|
||||
}
|
||||
|
|
|
@ -974,6 +974,7 @@ QtObject {
|
|||
readonly property string addAccountLabelImportNew: "LABEL-IMPORT-NEW"
|
||||
readonly property string addAccountLabelOptionAddNewMasterKey: "LABEL-OPTION-ADD-NEW-MASTER-KEY"
|
||||
readonly property string addAccountLabelOptionAddWatchOnlyAcc: "LABEL-OPTION-ADD-WATCH-ONLY-ACC"
|
||||
readonly property string keycardAccountNameOfUnknownWalletAccount: "KEYCARD-ACCOUNT-NAME-OF-UNKNOWN-WALLET-ACCOUNT"
|
||||
}
|
||||
|
||||
enum CommunitySettingsSections {
|
||||
|
|
|
@ -653,6 +653,12 @@ QtObject {
|
|||
return qsTr("Add watch-only account")
|
||||
}
|
||||
|
||||
// special handling because on an index attached to the constant
|
||||
if (key.startsWith(Constants.appTranslatableConstants.keycardAccountNameOfUnknownWalletAccount)) {
|
||||
let num = key.substring(Constants.appTranslatableConstants.keycardAccountNameOfUnknownWalletAccount.length)
|
||||
return "%1%2".arg(qsTr("acc")).arg(num) //short name of an unknown (removed) wallet account
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue