Browse Source

qml: don't duplicate invoice (e.g. when scanned twice)

also add invoice to invoiceModel from python, not qml
patch-4
Sander van Grieken 2 years ago
parent
commit
0c163a5322
  1. 4
      electrum/gui/qml/components/WalletMainView.qml
  2. 10
      electrum/gui/qml/qeinvoice.py

4
electrum/gui/qml/components/WalletMainView.qml

@ -191,10 +191,6 @@ Item {
var dialog = lnurlPayDialog.createObject(app, { invoiceParser: invoiceParser })
dialog.open()
}
onInvoiceSaved: {
Daemon.currentWallet.invoiceModel.addInvoice(key)
}
}
Component {

10
electrum/gui/qml/qeinvoice.py

@ -490,10 +490,14 @@ class QEInvoiceParser(QEInvoice):
self.canSave = False
if not self._effectiveInvoice:
return
# TODO detect duplicate?
self.key = self._effectiveInvoice.get_id()
self._wallet.wallet.save_invoice(self._effectiveInvoice)
self.invoiceSaved.emit(self.key)
if self._wallet.wallet.get_invoice(self.key):
self._logger.info(f'invoice {self.key} already exists')
else:
self._wallet.wallet.save_invoice(self._effectiveInvoice)
self._wallet.invoiceModel.addInvoice(self.key)
self.invoiceSaved.emit(self.key)
class QEUserEnteredPayment(QEInvoice):

Loading…
Cancel
Save