diff options
| author | Adam Soltys <[email protected]> | 2022-08-05 10:21:48 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-05 10:21:48 -0700 |
| commit | f0f318279775c3b306284c21b775bd5f1929ab54 (patch) | |
| tree | 974287d063e71ba5899d92f3dac3f1b1870824b6 /src/lib | |
| parent | 184251383e36928dad873518a0fc6d427ca91dbb (diff) | |
| download | coinos-ui-f0f318279775c3b306284c21b775bd5f1929ab54.tar.gz coinos-ui-f0f318279775c3b306284c21b775bd5f1929ab54.zip | |
lightning withdrawals
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/socket.js | 8 | ||||
| -rw-r--r-- | src/lib/utils.js | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js index c1b68a12..a30d4376 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -1,5 +1,6 @@ import { get } from 'svelte/store'; import { rate, user, token, invoices, preferredCurrency, newPayment } from '$lib/store'; +import { success } from '$lib/utils'; let interval, socket; @@ -18,8 +19,13 @@ export const messages = (data) => ({ }, payment() { - invoices.set({ ...get(invoices), [data.invoice.uuid]: data.invoice }); + if (data.invoice) invoices.set({ ...get(invoices), [data.invoice.uuid]: data.invoice }); newPayment.set(true); + if (data.amount > 0) { + success(`Received ${data.amount} sats!`); + } else { + success(`Sent ${-data.amount} sats!`); + } }, connected: auth, diff --git a/src/lib/utils.js b/src/lib/utils.js index a812c136..24f94d40 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -18,11 +18,12 @@ export const get = (url, headers = { accept: 'application/json' }) => } }); -export const post = (url, body) => - fetch(base + url, { +export const post = (url, body, headers) => { + headers = { ...headers, accept: 'application/json', 'content-type': 'application/json' }; + return fetch(base + url, { method: 'POST', body: JSON.stringify(body), - headers: { accept: 'application/json', 'content-type': 'application/json' } + headers }) .then((r) => r.text()) .then((body) => { @@ -37,6 +38,7 @@ export const post = (url, body) => return body; }); +} export const copy = (text) => { navigator.clipboard.writeText(text); |
