feat(airdrop): make the airdrop member selector use the airdropAddress

Fixes #11532

Hooks the Airdrop views to the new airdropAddress model property so that the fee calculation and the airdrop transaction can use a valid address.
This commit is contained in:
Jonathan Rainville 2023-07-20 15:58:51 -04:00
parent 5eaabe8ea6
commit 515028222e
3 changed files with 21 additions and 20 deletions

View File

@ -40,10 +40,8 @@ StackView {
property int viewWidth: 560 // by design
property string previousPageName: depth > 1 ? qsTr("Airdrops") : ""
signal airdropClicked(var airdropTokens, var addresses, var membersPubKeys,
string feeAccountAddress)
signal airdropFeesRequested(var contractKeysAndAmounts, var addresses,
string feeAccountAddress)
signal airdropClicked(var airdropTokens, var addresses, string feeAccountAddress)
signal airdropFeesRequested(var contractKeysAndAmounts, var addresses, string feeAccountAddress)
signal navigateToMintTokenSettings(bool isAssetType)
function navigateBack() {
@ -145,7 +143,7 @@ StackView {
}
onAirdropClicked: {
root.airdropClicked(airdropTokens, addresses, membersPubKeys)
root.airdropClicked(airdropTokens, addresses, feeAccountAddress)
root.pop(StackView.Immediate)
}

View File

@ -34,7 +34,7 @@ StatusDropdown {
property var keys: []
delegate: QtObject {
readonly property string key: model.pubKey
readonly property string key: model.airdropAddress
}
readonly property bool allSelected:
@ -194,10 +194,10 @@ StatusDropdown {
onClicked: {
const selectedKeysCopy = new Set([...root.selectedKeys])
if (root.selectedKeys.has(model.pubKey))
selectedKeysCopy.delete(model.pubKey)
if (root.selectedKeys.has(model.airdropAddress))
selectedKeysCopy.delete(model.airdropAddress)
else
selectedKeysCopy.add(model.pubKey)
selectedKeysCopy.add(model.airdropAddress)
root.selectedKeys = selectedKeysCopy
}
@ -207,7 +207,7 @@ StatusDropdown {
id: contactCheckbox
size: StatusCheckBox.Size.Small
checked: root.selectedKeys.has(model.pubKey)
checked: root.selectedKeys.has(model.airdropAddress)
MouseArea {
anchors.fill: parent

View File

@ -78,11 +78,9 @@ StatusScrollView {
airdropRecipientsSelector.count > 0 &&
airdropRecipientsSelector.valid
signal airdropClicked(var airdropTokens, var addresses, var membersPubKeys,
string feeAccountAddress)
signal airdropClicked(var airdropTokens, var addresses, string feeAccountAddress)
signal airdropFeesRequested(var contractKeysAndAmounts, var addresses,
string feeAccountAddress)
signal airdropFeesRequested(var contractKeysAndAmounts, var addresses, string feeAccountAddress)
signal navigateToMintTokenSettings(bool isAssetType)
@ -235,10 +233,12 @@ StatusScrollView {
const addressesArray = ModelUtils.modelToArray(
addresses, ["address"]).map(e => e.address)
const airdropAddresses = [...selectedKeysFilter.keys]
const accountItem = ModelUtils.get(root.accountsModel,
feesBox.accountIndex)
airdropFeesRequested(contractKeysAndAmounts, addressesArray,
airdropFeesRequested(contractKeysAndAmounts, addressesArray.concat(airdropAddresses),
accountItem.address)
}
@ -466,14 +466,14 @@ StatusScrollView {
property var keys: new Set()
expression: keys.has(model.pubKey)
expression: keys.has(model.airdropAddress) && model.airdropAddress !== ""
}
}
onRemoveMemberRequested: {
const pubKey = ModelUtils.get(membersModel, index, "pubKey")
const airdropAddress = ModelUtils.get(membersModel, index, "airdropAddress")
selectedKeysFilter.keys.delete(pubKey)
selectedKeysFilter.keys.delete(airdropAddress)
selectedKeysFilter.keys = new Set([...selectedKeysFilter.keys])
}
@ -572,6 +572,9 @@ StatusScrollView {
|| model.localNickname.toLowerCase().includes(filter)
|| model.pubKey.toLowerCase().includes(filter)
}
},
ExpressionFilter {
expression: !!model.airdropAddress
}
]
}
@ -667,9 +670,9 @@ StatusScrollView {
const addresses_ = ModelUtils.modelToArray(
addresses, ["address"]).map(e => e.address)
const pubKeys = [...selectedKeysFilter.keys]
const airdropAddresses = [...selectedKeysFilter.keys]
root.airdropClicked(airdropTokens, addresses_, pubKeys,
root.airdropClicked(airdropTokens, addresses_.concat(airdropAddresses),
accountAddress)
}
}