qml: allow user to delete invoices and requests from the list screen
also, delete expired requests before loading list
This commit is contained in:
@@ -9,6 +9,7 @@ import "controls"
|
|||||||
|
|
||||||
Pane {
|
Pane {
|
||||||
id: root
|
id: root
|
||||||
|
property string selected_key
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -39,7 +40,11 @@ Pane {
|
|||||||
dialog.invoiceAmountChanged.connect(function () {
|
dialog.invoiceAmountChanged.connect(function () {
|
||||||
Daemon.currentWallet.invoiceModel.init_model()
|
Daemon.currentWallet.invoiceModel.init_model()
|
||||||
})
|
})
|
||||||
|
selected_key = ''
|
||||||
}
|
}
|
||||||
|
onPressAndHold: {
|
||||||
|
selected_key = model.key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,5 +70,33 @@ Pane {
|
|||||||
ScrollIndicator.vertical: ScrollIndicator { }
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ButtonContainer {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
FlatButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredWidth: 1
|
||||||
|
text: qsTr('Delete')
|
||||||
|
icon.source: '../../icons/delete.png'
|
||||||
|
visible: selected_key != ''
|
||||||
|
onClicked: {
|
||||||
|
Daemon.currentWallet.delete_invoice(selected_key)
|
||||||
|
selected_key = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FlatButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredWidth: 1
|
||||||
|
text: qsTr('View')
|
||||||
|
icon.source: '../../icons/tab_receive.png'
|
||||||
|
visible: selected_key != ''
|
||||||
|
onClicked: {
|
||||||
|
var dialog = app.stack.getRoot().openInvoice(selected_key)
|
||||||
|
dialog.invoiceAmountChanged.connect(function () {
|
||||||
|
Daemon.currentWallet.invoiceModel.init_model()
|
||||||
|
})
|
||||||
|
selected_key = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import "controls"
|
|||||||
Pane {
|
Pane {
|
||||||
id: root
|
id: root
|
||||||
objectName: 'ReceiveRequests'
|
objectName: 'ReceiveRequests'
|
||||||
|
property string selected_key
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -38,14 +39,14 @@ Pane {
|
|||||||
model: Daemon.currentWallet.requestModel
|
model: Daemon.currentWallet.requestModel
|
||||||
delegate: InvoiceDelegate {
|
delegate: InvoiceDelegate {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// TODO: only open unpaid?
|
app.stack.getRoot().openRequest(model.key)
|
||||||
if (model.status == Invoice.Unpaid) {
|
selected_key = ''
|
||||||
app.stack.getRoot().openRequest(model.key)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
onPressAndHold: {
|
||||||
|
selected_key = model.key
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add: Transition {
|
add: Transition {
|
||||||
NumberAnimation { properties: 'scale'; from: 0.75; to: 1; duration: 500 }
|
NumberAnimation { properties: 'scale'; from: 0.75; to: 1; duration: 500 }
|
||||||
NumberAnimation { properties: 'opacity'; from: 0; to: 1; duration: 500 }
|
NumberAnimation { properties: 'opacity'; from: 0; to: 1; duration: 500 }
|
||||||
@@ -68,5 +69,30 @@ Pane {
|
|||||||
ScrollIndicator.vertical: ScrollIndicator { }
|
ScrollIndicator.vertical: ScrollIndicator { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ButtonContainer {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
FlatButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredWidth: 1
|
||||||
|
text: qsTr('Delete')
|
||||||
|
icon.source: '../../icons/delete.png'
|
||||||
|
visible: selected_key != ''
|
||||||
|
onClicked: {
|
||||||
|
Daemon.currentWallet.delete_request(selected_key)
|
||||||
|
selected_key = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FlatButton {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredWidth: 1
|
||||||
|
text: qsTr('View')
|
||||||
|
icon.source: '../../icons/tab_receive.png'
|
||||||
|
visible: selected_key != ''
|
||||||
|
onClicked: {
|
||||||
|
app.stack.getRoot().openRequest(selected_key)
|
||||||
|
selected_key = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ Item {
|
|||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
|
Daemon.currentWallet.delete_expired_requests()
|
||||||
app.stack.push(Qt.resolvedUrl('ReceiveRequests.qml'))
|
app.stack.push(Qt.resolvedUrl('ReceiveRequests.qml'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -608,17 +608,18 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
|
|
||||||
threading.Thread(target=pay_thread, daemon=True).start()
|
threading.Thread(target=pay_thread, daemon=True).start()
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def delete_expired_requests(self):
|
||||||
|
keys = self.wallet.delete_expired_requests()
|
||||||
|
for key in keys:
|
||||||
|
self.requestModel.delete_invoice(key)
|
||||||
|
|
||||||
@pyqtSlot(QEAmount, str, int)
|
@pyqtSlot(QEAmount, str, int)
|
||||||
@pyqtSlot(QEAmount, str, int, bool)
|
@pyqtSlot(QEAmount, str, int, bool)
|
||||||
@pyqtSlot(QEAmount, str, int, bool, bool)
|
@pyqtSlot(QEAmount, str, int, bool, bool)
|
||||||
@pyqtSlot(QEAmount, str, int, bool, bool, bool)
|
@pyqtSlot(QEAmount, str, int, bool, bool, bool)
|
||||||
def createRequest(self, amount: QEAmount, message: str, expiration: int, lightning_only: bool = False, reuse_address: bool = False):
|
def createRequest(self, amount: QEAmount, message: str, expiration: int, lightning_only: bool = False, reuse_address: bool = False):
|
||||||
# delete expired_requests
|
self.delete_expired_requests()
|
||||||
keys = self.wallet.delete_expired_requests()
|
|
||||||
for key in keys:
|
|
||||||
self.requestModel.delete_invoice(key)
|
|
||||||
try:
|
try:
|
||||||
amount = amount.satsInt
|
amount = amount.satsInt
|
||||||
addr = self.wallet.get_unused_address()
|
addr = self.wallet.get_unused_address()
|
||||||
|
|||||||
Reference in New Issue
Block a user