From a2efae3c3073fbc4d0526e9a348cf78e439f32a5 Mon Sep 17 00:00:00 2001
From: Tiago Vasconcelos
Date: Tue, 26 Sep 2023 12:43:51 +0100
Subject: [PATCH] Fix deleting last target (#7)
* fix deleting last target
---
README.md | 8 ++++----
static/js/index.js | 6 ++++--
tasks.py | 2 +-
templates/splitpayments/index.html | 6 ++++--
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 6b443e5..86d7656 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# Split Payments - [LNbits](https://github.com/lnbits/lnbits) extension
+
For more about LNBits extension check [this tutorial](https://github.com/lnbits/lnbits/wiki/LNbits-Documentation#use-cases-of-lnbits)
## Have payments split between multiple wallets
@@ -18,11 +19,11 @@ LNbits Split Payments extension allows for distributing payments across multiple
- set how much, in percentage, this wallet will receive from every payment sent to the source wallet
-3. When done with adding or deleting a set of targets, click "SAVE TARGETS" to make the splits effective.
+3. When done with adding or deleting a set of targets, click "SAVE TARGETS" to make the splits effective.
4. You can have several wallets to split to, as long as the sum of the percentages is under or equal to 100%. It can only reach 100% if the targets are all internal ones.
-5. When the source wallet receives a payment, the extension will automatically split the corresponding values to every wallet.
+5. When the source wallet receives a payment, the extension will automatically split the corresponding values to every wallet.
- on receiving a 20 sats payment\

- source wallet gets 18 sats\
@@ -33,13 +34,12 @@ LNbits Split Payments extension allows for distributing payments across multiple
IMPORTANT:
- If you split to a LNURLp or LNaddress through the LNURLp extension make sure your receipients allow comments ! Split&Scrub add a comment in your transaction - and if it is not allowed, the split/scrub will not take place.
-- Make sure the LNURLp / LNaddress of the receipient has its min-sats set very low (e.g. 1 sat). If the wallet does not belong to you you can [check with a Decoder](https://lightningdecoder.com/), if that is the case already
+- Make sure the LNURLp / LNaddress of the receipient has its min-sats set very low (e.g. 1 sat). If the wallet does not belong to you you can [check with a Decoder](https://lightningdecoder.com/), if that is the case already
- Yes, there is fees - internal and external! Updating your own wallets on your own instance will not cost any fees but sending to an external instance will. Please notice that you should therefore not split up to 100% if you send to a wallet that is external (leave 1-2% reserve for routing fees!). External fees are deducted from the individual payment percentage of the receipient
-
## Sponsored by
[](https://cryptograffiti.com/)
diff --git a/static/js/index.js b/static/js/index.js
index 7e334ac..1ea7a8c 100644
--- a/static/js/index.js
+++ b/static/js/index.js
@@ -34,8 +34,10 @@ new Vue({
},
methods: {
clearTarget(index) {
+ if(this.targets.length == 1) {
+ return this.deleteTargets()
+ }
this.targets.splice(index, 1)
- console.log(this.targets)
this.$q.notify({
message: 'Removed item. You must click to save manually.',
timeout: 500
@@ -84,7 +86,7 @@ new Vue({
},
deleteTargets() {
LNbits.utils
- .confirmDialog('Are you sure you want to delete the targets?')
+ .confirmDialog('Are you sure you want to delete all targets?')
.onOk(() => {
this.targets = []
LNbits.api
diff --git a/tasks.py b/tasks.py
index 9bf381d..13b1659 100644
--- a/tasks.py
+++ b/tasks.py
@@ -9,7 +9,7 @@ from loguru import logger
from lnbits import bolt11
from lnbits.core.crud import get_standalone_payment
from lnbits.core.models import Payment
-from lnbits.core.services import create_invoice, pay_invoice, fee_reserve
+from lnbits.core.services import create_invoice, fee_reserve, pay_invoice
from lnbits.helpers import get_current_extension_name
from lnbits.tasks import register_invoice_listener
diff --git a/templates/splitpayments/index.html b/templates/splitpayments/index.html
index 307efc5..d14dcfc 100644
--- a/templates/splitpayments/index.html
+++ b/templates/splitpayments/index.html
@@ -118,10 +118,12 @@
This is valid for every payment, doesn't matter how it was created.
- Targets can be LNBits wallets from this LNBits instance or any valid LNURL or LN Address.
+ Targets can be LNBits wallets from this LNBits instance or any valid
+ LNURL or LN Address.
- LNURLp and LN Addresses must allow comments > 100 chars and also have a flexible amount.
+ LNURLp and LN Addresses must allow comments > 100 chars and also
+ have a flexible amount.
To remove a wallet from the targets list just press the X and save.