qt: do not mutate already saved invoice after editing amount.
Also show empty an string for invoices that do not have an amount, similar to the requests list.
This commit is contained in:
@@ -119,11 +119,12 @@ class InvoiceList(MyTreeView):
|
|||||||
icon_name = 'seal.png'
|
icon_name = 'seal.png'
|
||||||
status = self.wallet.get_invoice_status(item)
|
status = self.wallet.get_invoice_status(item)
|
||||||
amount = item.get_amount_sat()
|
amount = item.get_amount_sat()
|
||||||
|
amount_str = self.main_window.format_amount(amount, whitespaces=True) if amount else ""
|
||||||
timestamp = item.time or 0
|
timestamp = item.time or 0
|
||||||
labels = [""] * len(self.Columns)
|
labels = [""] * len(self.Columns)
|
||||||
labels[self.Columns.DATE] = format_time(timestamp) if timestamp else _('Unknown')
|
labels[self.Columns.DATE] = format_time(timestamp) if timestamp else _('Unknown')
|
||||||
labels[self.Columns.DESCRIPTION] = item.message
|
labels[self.Columns.DESCRIPTION] = item.message
|
||||||
labels[self.Columns.AMOUNT] = self.main_window.format_amount(amount, whitespaces=True)
|
labels[self.Columns.AMOUNT] = amount_str
|
||||||
labels[self.Columns.STATUS] = item.get_status_str(status)
|
labels[self.Columns.STATUS] = item.get_status_str(status)
|
||||||
items = [QStandardItem(e) for e in labels]
|
items = [QStandardItem(e) for e in labels]
|
||||||
self.set_editability(items)
|
self.set_editability(items)
|
||||||
@@ -182,7 +183,7 @@ class InvoiceList(MyTreeView):
|
|||||||
if bool(invoice.get_amount_sat()):
|
if bool(invoice.get_amount_sat()):
|
||||||
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice))
|
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice))
|
||||||
else:
|
else:
|
||||||
menu.addAction(_("Edit amount") + "...", lambda: self.send_tab.do_edit_invoice(invoice))
|
menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_edit_invoice(invoice))
|
||||||
if status == PR_FAILED:
|
if status == PR_FAILED:
|
||||||
menu.addAction(_("Retry"), lambda: self.send_tab.do_pay_invoice(invoice))
|
menu.addAction(_("Retry"), lambda: self.send_tab.do_pay_invoice(invoice))
|
||||||
if self.wallet.lnworker:
|
if self.wallet.lnworker:
|
||||||
|
|||||||
@@ -585,6 +585,8 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
text = invoice.lightning_invoice if invoice.is_lightning() else invoice.get_address()
|
text = invoice.lightning_invoice if invoice.is_lightning() else invoice.get_address()
|
||||||
self.payto_e._on_input_btn(text)
|
self.payto_e._on_input_btn(text)
|
||||||
self.amount_e.setFocus()
|
self.amount_e.setFocus()
|
||||||
|
# disable save button, because it would create a new invoice
|
||||||
|
self.save_button.setEnabled(False)
|
||||||
|
|
||||||
def do_pay_invoice(self, invoice: 'Invoice'):
|
def do_pay_invoice(self, invoice: 'Invoice'):
|
||||||
if not bool(invoice.get_amount_sat()):
|
if not bool(invoice.get_amount_sat()):
|
||||||
|
|||||||
Reference in New Issue
Block a user