diff options
| author | Adam Soltys <[email protected]> | 2024-11-08 15:19:04 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-08 15:19:04 -0800 |
| commit | 84fb4b209a2650b2a93f3208ee9a23a44d8283c7 (patch) | |
| tree | 8687566bd8eac12de99439d448773d8ce5dc34b4 /src/routes/(app)/invoice | |
| parent | 32fcc461cd43c8907df5e306d520bb671307eab1 (diff) | |
| download | coinos-ui-84fb4b209a2650b2a93f3208ee9a23a44d8283c7.tar.gz coinos-ui-84fb4b209a2650b2a93f3208ee9a23a44d8283c7.zip | |
svelte 5 fixups
Diffstat (limited to 'src/routes/(app)/invoice')
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+layout.server.ts | 1 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.svelte | 63 |
2 files changed, 20 insertions, 44 deletions
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts index e428d9fe..9b667c7b 100644 --- a/src/routes/(app)/invoice/[id]/+layout.server.ts +++ b/src/routes/(app)/invoice/[id]/+layout.server.ts @@ -35,6 +35,7 @@ export async function load({ cookies, depends, params, url, parent }) { } } + console.log("REDRAW", invoice?.text); const src = Qr.drawImg(invoice?.text || "", { size: 500 }); const theme = cookies.get("theme"); return { id, invoice, subject, src, user, token, theme }; diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index fef43e4d..ded42016 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -26,7 +26,8 @@ let readingerror = (e) => console.log("nfc error", e); - let { invoice, id, subject, user, src } = $state(data); + let { invoice, id, subject, user } = $state(data); + let src = $derived(data.src); let { aid, amount, @@ -38,32 +39,15 @@ user: { username, currency }, } = $state(invoice); - let qr = $state(); - let tipPercent = 0; + let tipPercent = $derived(tip ? (tip / amount) * 100 : 0); - let refresh = async (data) => { - ({ invoice, id, user, src } = data); - ({ - aid, - amount, - hash, - type, - rate, - text, - tip, - user: { username, currency }, - } = invoice); - - if (browser && !subbed[id]) - send("subscribe", invoice) - .then(() => (subbed[id] = true)) - .catch((e) => { - console.log("failed to subscribe to invoice notifications", invoice); - console.log(e); - }); - - tipPercent = (tip / amount) * 100; - }; + // if (browser && !subbed[id]) + // send("subscribe", invoice) + // .then(() => (subbed[id] = true)) + // .catch((e) => { + // console.log("failed to subscribe to invoice notifications", invoice); + // console.log(e); + // }); let subbed = {}; @@ -90,6 +74,7 @@ }; let setAmount = $state(async () => { + console.log("LALA", newAmount); if (typeof $amountPrompt === "undefined") $amountPrompt = true; settingAmount = false; amount = newAmount; @@ -104,6 +89,7 @@ if (subject?.prompt) url += "/tip"; else url += "?options=true"; + console.log("GO", url); goto(url, { invalidateAll: true, noScroll: true }); }); @@ -112,31 +98,20 @@ let toggleAmount = $state(() => (settingAmount = !settingAmount)); let fiat = $state(true); let submit = $state(); - run(() => { - refresh(data); - }); - let amountFiat; - run(() => { - amountFiat = parseFloat(((amount * rate) / sats).toFixed(2)); - }); + let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2))); let tipAmount = $derived(((tip * rate) / sats).toFixed(2)); - let link; - run(() => { - link = [types.bitcoin, types.liquid].includes(type) - ? text - : `lightning:${text}`; - }); - let txt; - run(() => { - txt = [types.bitcoin, types.liquid].includes(type) ? hash : text; - }); + let link = $derived( + [types.bitcoin, types.liquid].includes(type) ? text : `lightning:${text}`, + ); + let txt = $derived( + [types.bitcoin, types.liquid].includes(type) ? hash : text, + ); </script> <div class="invoice container mx-auto max-w-xl px-4 space-y-2"> <InvoiceData {src} {link} - {qr} {txt} {invoice} {amount} |
