fix(@desktop/onboarding): do not display keyid as address

fixes #3035
This commit is contained in:
Anthony Laibe 2021-07-26 09:17:49 +02:00 committed by Iuri Matias
parent 39dace238b
commit 75c986cc77
10 changed files with 31 additions and 37 deletions

View File

@ -10,9 +10,9 @@ type
AccountRoles {.pure.} = enum AccountRoles {.pure.} = enum
Username = UserRole + 1 Username = UserRole + 1
Identicon = UserRole + 2 Identicon = UserRole + 2
Address = UserRole + 3 ThumbnailImage = UserRole + 3
ThumbnailImage = UserRole + 4 LargeImage = UserRole + 4
LargeImage = UserRole + 5 KeyUid = UserRole + 5
QtObject: QtObject:
type LoginView* = ref object of QAbstractListModel type LoginView* = ref object of QAbstractListModel
@ -45,7 +45,6 @@ QtObject:
self.currentAccount.setAccount(GeneratedAccount( self.currentAccount.setAccount(GeneratedAccount(
name: currNodeAcct.name, name: currNodeAcct.name,
identicon: currNodeAcct.identicon, identicon: currNodeAcct.identicon,
address: currNodeAcct.keyUid,
keyUid: currNodeAcct.keyUid, keyUid: currNodeAcct.keyUid,
identityImage: currNodeAcct.identityImage identityImage: currNodeAcct.identityImage
)) ))
@ -80,7 +79,7 @@ QtObject:
case assetRole: case assetRole:
of AccountRoles.Username: result = newQVariant(asset.name) of AccountRoles.Username: result = newQVariant(asset.name)
of AccountRoles.Identicon: result = newQVariant(asset.identicon) of AccountRoles.Identicon: result = newQVariant(asset.identicon)
of AccountRoles.Address: result = newQVariant(asset.keyUid) of AccountRoles.KeyUid: result = newQVariant(asset.keyUid)
of AccountRoles.ThumbnailImage: of AccountRoles.ThumbnailImage:
if (not asset.identityImage.isNil): if (not asset.identityImage.isNil):
result = newQVariant(asset.identityImage.thumbnail) result = newQVariant(asset.identityImage.thumbnail)
@ -95,15 +94,15 @@ QtObject:
method roleNames(self: LoginView): Table[int, string] = method roleNames(self: LoginView): Table[int, string] =
{ AccountRoles.Username.int:"username", { AccountRoles.Username.int:"username",
AccountRoles.Identicon.int:"identicon", AccountRoles.Identicon.int:"identicon",
AccountRoles.Address.int:"address",
AccountRoles.ThumbnailImage.int:"thumbnailImage", AccountRoles.ThumbnailImage.int:"thumbnailImage",
AccountRoles.LargeImage.int:"largeImage" }.toTable AccountRoles.LargeImage.int:"largeImage",
AccountRoles.KeyUid.int:"keyUid" }.toTable
proc login(self: LoginView, password: string): string {.slot.} = proc login(self: LoginView, password: string): string {.slot.} =
var currentAccountId = 0 var currentAccountId = 0
var i = 0 var i = 0
for account in self.accounts: for account in self.accounts:
if (account.keyUid == self.currentAccount.address): if (account.keyUid == self.currentAccount.keyUid):
currentAccountId = i currentAccountId = i
break break
i = i + 1 i = i + 1

View File

@ -9,7 +9,8 @@ type
AccountRoles {.pure.} = enum AccountRoles {.pure.} = enum
Username = UserRole + 1, Username = UserRole + 1,
Identicon = UserRole + 2, Identicon = UserRole + 2,
Address = UserRole + 3 KeyUid = UserRole + 3,
Address = UserRole + 4
QtObject: QtObject:
type OnboardingView* = ref object of QAbstractListModel type OnboardingView* = ref object of QAbstractListModel
@ -59,11 +60,13 @@ QtObject:
case assetRole: case assetRole:
of AccountRoles.Username: result = newQVariant(asset.name) of AccountRoles.Username: result = newQVariant(asset.name)
of AccountRoles.Identicon: result = newQVariant(asset.identicon) of AccountRoles.Identicon: result = newQVariant(asset.identicon)
of AccountRoles.Address: result = newQVariant(asset.keyUid) of AccountRoles.KeyUid: result = newQVariant(asset.keyUid)
of AccountRoles.Address: result = newQVariant(asset.address)
method roleNames(self: OnboardingView): Table[int, string] = method roleNames(self: OnboardingView): Table[int, string] =
{ AccountRoles.Username.int:"username", { AccountRoles.Username.int:"username",
AccountRoles.Identicon.int:"identicon", AccountRoles.Identicon.int:"identicon",
AccountRoles.KeyUid.int:"keyUid",
AccountRoles.Address.int:"address" }.toTable AccountRoles.Address.int:"address" }.toTable
proc storeAccountAndLogin(self: OnboardingView, selectedAccountIndex: int, password: string): string {.slot.} = proc storeAccountAndLogin(self: OnboardingView, selectedAccountIndex: int, password: string): string {.slot.} =

View File

@ -52,9 +52,9 @@ QtObject:
read = largeImage read = largeImage
notify = identityImageChanged notify = identityImageChanged
proc address*(self: AccountInfoView): string {.slot.} = result = ?.self.account.address proc keyUid*(self: AccountInfoView): string {.slot.} = result = ?.self.account.keyUid
QtProperty[string] address: QtProperty[string] keyUid:
read = address read = keyUid
notify = accountChanged notify = accountChanged
proc id*(self: AccountInfoView): string {.slot.} = result = ?.self.account.id proc id*(self: AccountInfoView): string {.slot.} = result = ?.self.account.id

View File

@ -354,7 +354,7 @@ DISTFILES += \
onboarding/KeysMain.qml \ onboarding/KeysMain.qml \
onboarding/Login.qml \ onboarding/Login.qml \
onboarding/Login/AccountList.qml \ onboarding/Login/AccountList.qml \
onboarding/Login/AddressView.qml \ onboarding/Login/AccountView.qml \
onboarding/Login/ConfirmAddExistingKeyModal.qml \ onboarding/Login/ConfirmAddExistingKeyModal.qml \
onboarding/Login/SelectAnotherAccountModal.qml \ onboarding/Login/SelectAnotherAccountModal.qml \
onboarding/Login/qmldir \ onboarding/Login/qmldir \

View File

@ -20,7 +20,7 @@ ModalPopup {
interactive: false interactive: false
accounts: onboardingModel accounts: onboardingModel
isSelected: function (index, address) { isSelected: function (index) {
return index === selectedIndex return index === selectedIndex
} }
onAccountSelect: function(index) { onAccountSelect: function(index) {

View File

@ -114,19 +114,9 @@ Item {
} }
} }
Address {
id: addressText
width: 90
text: loginModel.currentAccount.address
font.pixelSize: 15
anchors.top: usernameText.bottom
anchors.topMargin: 4
anchors.horizontalCenter: parent.horizontalCenter
}
Input { Input {
id: txtPassword id: txtPassword
anchors.top: addressText.bottom anchors.top: changeAccountBtn.bottom
anchors.topMargin: Style.current.padding * 2 anchors.topMargin: Style.current.padding * 2
enabled: !loading enabled: !loading
//% "Enter password" //% "Enter password"

View File

@ -8,22 +8,23 @@ ListView {
property var isSelected: function () {} property var isSelected: function () {}
property var onAccountSelect: function () {} property var onAccountSelect: function () {}
id: addressesView id: accountsView
anchors.fill: parent anchors.fill: parent
model: accounts model: accounts
focus: true focus: true
spacing: Style.current.smallPadding spacing: Style.current.smallPadding
clip: true clip: true
delegate: AddressView { delegate: AccountView {
username: model.username username: model.username
address: model.address
identicon: model.thumbnailImage || model.identicon identicon: model.thumbnailImage || model.identicon
isSelected: function (index, address) { keyUid: model.keyUid
return addressesView.isSelected(index, address) address: model.address || ''
isSelected: function (index, keyUid) {
return accountsView.isSelected(index, keyUid)
} }
onAccountSelect: function (index) { onAccountSelect: function (index) {
addressesView.onAccountSelect(index) accountsView.onAccountSelect(index)
} }
} }
} }

View File

@ -6,12 +6,13 @@ import "../../shared/status"
Rectangle { Rectangle {
property string username: "Jotaro Kujo" property string username: "Jotaro Kujo"
property string address: "0x123345677890987654321123456" property string keyUid: "0x123345677890987654321123456"
property string address: ""
property url identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAg0lEQVR4nOzXwQmAMBAFURV7sQybsgybsgyr0QYUlE1g+Mw7ioQMe9lMQwhDaAyhMYTGEJqYkPnrj/t5XE/ft2UdW1yken7MRAyhMYTGEBpDaAyhKe9JbzvSX9WdLWYihtAYQuMLkcYQGkPUScxEDKExhMYQGkNoDKExhMYQmjsAAP//ZfIUZgXTZXQAAAAASUVORK5CYII=" property url identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAg0lEQVR4nOzXwQmAMBAFURV7sQybsgybsgyr0QYUlE1g+Mw7ioQMe9lMQwhDaAyhMYTGEJqYkPnrj/t5XE/ft2UdW1yken7MRAyhMYTGEBpDaAyhKe9JbzvSX9WdLWYihtAYQuMLkcYQGkPUScxEDKExhMYQGkNoDKExhMYQmjsAAP//ZfIUZgXTZXQAAAAASUVORK5CYII="
property var onAccountSelect: function() {} property var onAccountSelect: function() {}
property var isSelected: function() {} property var isSelected: function() {}
property bool selected: { property bool selected: {
return isSelected(index, address) return isSelected(index, keyUid)
} }
property bool isHovered: false property bool isHovered: false

View File

@ -16,8 +16,8 @@ ModalPopup {
anchors.fill: parent anchors.fill: parent
accounts: loginModel accounts: loginModel
isSelected: function (index, address) { isSelected: function (index, keyUid) {
return loginModel.currentAccount.address === address return loginModel.currentAccount.keyUid === keyUid
} }
onAccountSelect: function(index) { onAccountSelect: function(index) {

View File

@ -1,4 +1,4 @@
AccountList 1.0 AccountList.qml AccountList 1.0 AccountList.qml
AddressView 1.0 AddressView.qml AccountView 1.0 AccountView.qml
SelectAnotherAccountModal 1.0 SelectAnotherAccountModal.qml SelectAnotherAccountModal 1.0 SelectAnotherAccountModal.qml
ConfirmAddExistingKeyModal 1.0 ConfirmAddExistingKeyModal.qml ConfirmAddExistingKeyModal 1.0 ConfirmAddExistingKeyModal.qml