Don't set a default payment ID on receive page

This commit is contained in:
Michael Campagnaro 2017-03-18 18:01:00 -04:00
parent aeea9ad324
commit 43a33e717d

View file

@ -51,16 +51,22 @@ Rectangle {
function updatePaymentId(payment_id) { function updatePaymentId(payment_id) {
if (typeof appWindow.currentWallet === 'undefined' || appWindow.currentWallet == null) if (typeof appWindow.currentWallet === 'undefined' || appWindow.currentWallet == null)
return return
// generate a new one if not given as argument // generate a new one if not given as argument
if (typeof payment_id === 'undefined') { if (typeof payment_id === 'undefined') {
payment_id = appWindow.currentWallet.generatePaymentId() payment_id = appWindow.currentWallet.generatePaymentId()
appWindow.persistentSettings.payment_id = payment_id
paymentIdLine.text = payment_id paymentIdLine.text = payment_id
} }
addressLine.text = appWindow.currentWallet.address
integratedAddressLine.text = appWindow.currentWallet.integratedAddress(payment_id) if (payment_id.length > 0) {
if (integratedAddressLine.text === "") integratedAddressLine.text = appWindow.currentWallet.integratedAddress(payment_id)
integratedAddressLine.text = qsTr("Invalid payment ID") if (integratedAddressLine.text === "")
integratedAddressLine.text = qsTr("Invalid payment ID")
}
else {
integratedAddressLine.text = ""
}
update() update()
} }
@ -243,13 +249,10 @@ Rectangle {
pressedColor: "#FF4304" pressedColor: "#FF4304"
text: qsTr("Generate") + translationManager.emptyString; text: qsTr("Generate") + translationManager.emptyString;
anchors.right: parent.right anchors.right: parent.right
onClicked: { onClicked: updatePaymentId()
appWindow.persistentSettings.payment_id = appWindow.currentWallet.generatePaymentId();
updatePaymentId()
}
} }
} }
RowLayout { RowLayout {
id: integratedAddressRow id: integratedAddressRow
Label { Label {
@ -414,12 +417,14 @@ Rectangle {
function onPageCompleted() { function onPageCompleted() {
console.log("Receive page loaded"); console.log("Receive page loaded");
if(addressLine.text.length === 0 || addressLine.text !== appWindow.currentWallet.address) { if (appWindow.currentWallet) {
updatePaymentId() if (addressLine.text.length === 0 || addressLine.text !== appWindow.currentWallet.address) {
addressLine.text = appWindow.currentWallet.address
}
} }
update() update()
timer.running = true timer.running = true
} }
function onPageClosed() { function onPageClosed() {