From 202eea6e484b562961a72f98a642122d0e0f8086 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 14 Nov 2024 13:32:52 -0800 Subject: payment amount helpers --- src/routes/(app)/payment/[id]/+page.svelte | 40 +++--------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'src/routes/(app)/payment') diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 45dc8642..94226931 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -25,31 +25,6 @@ let { user, payment: p } = $state(data); let locale = locales[user.language]; - let refresh = (d) => { - ({ user, payment: p } = d); - ({ - id, - hash, - amount, - created, - confirmed, - memo, - rate, - type, - ref, - path, - tip, - ourfee, - fee, - currency, - } = p); - - if (amount > 0) [txid, vout] = ref.split(":"); - else txid = hash; - - if (!fee) fee = 0; - }; - let { username } = user; let { id, @@ -64,9 +39,10 @@ path, tip, ourfee, - fee, + fee = 0, currency, - } = $state(p); + } = $derived(p); + let [txid, vout] = $derived(amount > 0 ? ref.split(":") : [hash]); let a = Math.abs(amount); let expl = { @@ -87,11 +63,6 @@ } }; - let txid = $state(), - vout = $state(); - if (amount > 0) [txid, vout] = ref.split(":"); - else txid = hash; - let direction = $state(""); onMount(() => { direction = amount > 0 ? $t("payments.from") : $t("payments.to"); @@ -100,9 +71,6 @@ direction = direction[0].toUpperCase() + direction.substr(1, direction.length); }); - run(() => { - refresh(data); - }); {#snippet field(title, amount)} @@ -111,7 +79,7 @@
{amount} + >{s(amount)}
{f(toFiat(amount, rate), currency)} -- cgit v1.2.3