aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-18 09:08:07 -0700
committerAdam Soltys <[email protected]>2024-10-18 09:09:14 -0700
commit002cd9134d2e23bec34f838f6d6fefba41f2d530 (patch)
tree92fa0e0ab54ce1a715d25f458de8b8ed8cc70bd5 /src/routes/(app)
parentf6bfe889d91bc6e36b0300d7b618f10158efe176 (diff)
downloadcoinos-ui-002cd9134d2e23bec34f838f6d6fefba41f2d530.tar.gz
coinos-ui-002cd9134d2e23bec34f838f6d6fefba41f2d530.zip
biome format
Diffstat (limited to 'src/routes/(app)')
-rw-r--r--src/routes/(app)/+layout.svelte6
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.server.ts4
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte18
-rw-r--r--src/routes/(app)/[username]/(profile)/followers/+page.svelte8
-rw-r--r--src/routes/(app)/[username]/(profile)/follows/+page.svelte6
-rw-r--r--src/routes/(app)/[username]/+layout.server.ts2
-rw-r--r--src/routes/(app)/account/[id]/+page.server.ts3
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte4
-rw-r--r--src/routes/(app)/account/pass/+page.svelte4
-rw-r--r--src/routes/(app)/account/savings/+page.svelte4
-rw-r--r--src/routes/(app)/account/setup/+page.svelte3
-rw-r--r--src/routes/(app)/admin/+page.server.ts2
-rw-r--r--src/routes/(app)/ecash/[id]/[...version]/+layout.svelte4
-rw-r--r--src/routes/(app)/ecash/[id]/[...version]/swap/+page.server.ts2
-rw-r--r--src/routes/(app)/ecash/[id]/[...version]/swap/+page.svelte4
-rw-r--r--src/routes/(app)/invoice/+page.server.ts2
-rw-r--r--src/routes/(app)/invoice/+server.ts6
-rw-r--r--src/routes/(app)/invoice/[id]/+page.svelte2
-rw-r--r--src/routes/(app)/invoice/[id]/tip/+page.server.ts7
-rw-r--r--src/routes/(app)/ln/[lnurl]/+page.server.ts5
-rw-r--r--src/routes/(app)/messages/+page.server.ts6
-rw-r--r--src/routes/(app)/messages/[recipient]/+page.server.ts3
-rw-r--r--src/routes/(app)/messages/[recipient]/+page.svelte6
-rw-r--r--src/routes/(app)/otpsecret/+server.ts2
-rw-r--r--src/routes/(app)/pay/[username]/[...amount]/+page.server.ts4
-rw-r--r--src/routes/(app)/payments/[...page]/+page.svelte2
-rw-r--r--src/routes/(app)/qr/[text]/+page.svelte16
-rw-r--r--src/routes/(app)/receive/[...token]/+page.server.ts6
-rw-r--r--src/routes/(app)/send/[...text]/+page.server.ts2
-rw-r--r--src/routes/(app)/send/[...text]/+page.svelte3
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts2
-rw-r--r--src/routes/(app)/send/lightning/[payreq]/+page.svelte16
-rw-r--r--src/routes/(app)/sent/[id]/+page.server.ts2
-rw-r--r--src/routes/(app)/sent/[id]/+page.svelte5
-rw-r--r--src/routes/(app)/settings/[...tab]/+page.svelte8
-rw-r--r--src/routes/(app)/settings/[...tab]/_pos.svelte44
-rw-r--r--src/routes/(app)/subscription/+server.ts11
37 files changed, 153 insertions, 81 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte
index db14b046..d8519a1f 100644
--- a/src/routes/(app)/+layout.svelte
+++ b/src/routes/(app)/+layout.svelte
@@ -19,7 +19,7 @@
import Password from "$comp/Password.svelte";
import { getCookie, warning, protectedRoutes } from "$lib/utils";
import { t, locale, loading } from "$lib/translations";
- import { goto, onNavigate } from "$app/navigation";
+ import { goto, afterNavigate, preloadData } from "$app/navigation";
export let data;
@@ -30,6 +30,10 @@
({ rate, user, subject, token, rates } = data);
};
+ afterNavigate(() => {
+ preloadData(`/${user.username}/receive`);
+ });
+
onMount(async () => {
if (browser) {
checkSocket();
diff --git a/src/routes/(app)/[username]/(profile)/+layout.server.ts b/src/routes/(app)/[username]/(profile)/+layout.server.ts
index 73a24397..4592b81e 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.server.ts
+++ b/src/routes/(app)/[username]/(profile)/+layout.server.ts
@@ -8,7 +8,9 @@ export async function load({ depends, parent }) {
let { follows, followers } = await get(`/${subject.pubkey}/count`);
let followList = new Promise((r) => r([]));
if (user)
- followList = get(`/${user.pubkey}/follows?pubkeysOnly=true`).catch(() => []);
+ followList = get(`/${user.pubkey}/follows?pubkeysOnly=true`).catch(
+ () => [],
+ );
return { follows, followers, followList };
}
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index d48fa279..5ad30f46 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -54,7 +54,7 @@
let follow = async () => {
list = [...list, subject.pubkey];
let tags = await get(
- `/api/${user.pubkey}/follows?pubkeysOnly=true&nocache=true`
+ `/api/${user.pubkey}/follows?pubkeysOnly=true&nocache=true`,
);
tags.push(["p", subject.pubkey]);
await update(tags);
@@ -64,15 +64,15 @@
let unfollow = async () => {
list.splice(
list.findIndex((t) => t[1] === subject.pubkey),
- 1
+ 1,
);
list = list;
let tags = await get(
- `/api/${user.pubkey}/follows?pubkeysOnly=true&nocache=true`
+ `/api/${user.pubkey}/follows?pubkeysOnly=true&nocache=true`,
);
tags.splice(
tags.findIndex((t) => t[1] === subject.pubkey),
- 1
+ 1,
);
await update(tags);
};
@@ -151,13 +151,17 @@
<div>
<div class="flex justify-center gap-2">
- <a href={`/${subject.pubkey}/follows`} data-sveltekit-preload-data="tap" rel="nofollow"
+ <a
+ href={`/${subject.pubkey}/follows`}
+ data-sveltekit-preload-data="tap"
+ rel="nofollow"
><b>{si(follows)}</b>
<span class="text-secondary">{$t("user.following")}</span></a
>
<a
href={`/${subject.pubkey}/followers`}
- data-sveltekit-preload-data="tap" rel="nofollow"
+ data-sveltekit-preload-data="tap"
+ rel="nofollow"
><b>{si(followers)}</b>
<span class="text-secondary">{$t("user.followers")}</span></a
>
@@ -199,7 +203,7 @@
>
<a
href={`/qr/${encodeURIComponent(
- `${$page.url.protocol}//${profile}`
+ `${$page.url.protocol}//${profile}`,
)}`}
class="my-auto"
>
diff --git a/src/routes/(app)/[username]/(profile)/followers/+page.svelte b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
index 19e4a9aa..c0080990 100644
--- a/src/routes/(app)/[username]/(profile)/followers/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
@@ -14,11 +14,15 @@
</h1>
{#await followers}
- <div>Loading followers...</div>
+ <div>Loading followers...</div>
{:then followers}
{#if followers.length}
<VirtualScroll data={followers} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}`} data-sveltekit-preload-data="tap" rel="nofollow">
+ <a
+ href={`/${data.pubkey}`}
+ data-sveltekit-preload-data="tap"
+ rel="nofollow"
+ >
<div
class="flex border-b last:border-b-0 py-4 text-2xl text-secondary"
:key={data.pubkey}
diff --git a/src/routes/(app)/[username]/(profile)/follows/+page.svelte b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
index 496a81e1..9b2f70d1 100644
--- a/src/routes/(app)/[username]/(profile)/follows/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
@@ -23,7 +23,11 @@
{#if follows.length}
{#if browser}
<VirtualScroll data={follows} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}`} data-sveltekit-preload-data="tap" rel="nofollow">
+ <a
+ href={`/${data.pubkey}`}
+ data-sveltekit-preload-data="tap"
+ rel="nofollow"
+ >
<div class="flex py-4 text-lg text-secondary" :key={data.pubkey}>
<div class="mb-auto mr-2">
<div class="md:hidden">
diff --git a/src/routes/(app)/[username]/+layout.server.ts b/src/routes/(app)/[username]/+layout.server.ts
index 1b95bdd0..c7a5c44b 100644
--- a/src/routes/(app)/[username]/+layout.server.ts
+++ b/src/routes/(app)/[username]/+layout.server.ts
@@ -9,7 +9,7 @@ export let load = async ({
}) => {
depends("app:user");
- try {
+ try {
let subject = await get(`/users/${username}`);
let { user } = await parent();
diff --git a/src/routes/(app)/account/[id]/+page.server.ts b/src/routes/(app)/account/[id]/+page.server.ts
index 35b5517d..e521f15b 100644
--- a/src/routes/(app)/account/[id]/+page.server.ts
+++ b/src/routes/(app)/account/[id]/+page.server.ts
@@ -1,11 +1,10 @@
import { error, redirect } from "@sveltejs/kit";
import { auth, get, post, fd } from "$lib/utils";
-
export let load = async ({ cookies, params }) => {
let account = await get(`/account/${params.id}`, auth(cookies));
return { account };
-}
+};
export const actions = {
default: async ({ cookies, params, request }) => {
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index 3f7bb900..63fd7a42 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -37,10 +37,10 @@
}
};
-let nwc;
+ let nwc;
let revealNwc = () =>
(nwc = `nostr+walletconnect://${pk}?relay=${encodeURIComponent(
- relay
+ relay,
)}&secret=${user.nwc}`);
</script>
diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte
index c063d647..5becf337 100644
--- a/src/routes/(app)/account/pass/+page.svelte
+++ b/src/routes/(app)/account/pass/+page.svelte
@@ -39,12 +39,12 @@
try {
let seed = await encrypt(
mnemonicToEntropy($mnemonic, wordlist),
- password
+ password,
);
let master = HDKey.fromMasterSeed(
await mnemonicToSeed($mnemonic, password),
- versions
+ versions,
);
let child = master.derive("m/84'/0'/0'");
diff --git a/src/routes/(app)/account/savings/+page.svelte b/src/routes/(app)/account/savings/+page.svelte
index f9c6305c..8cc24aa2 100644
--- a/src/routes/(app)/account/savings/+page.svelte
+++ b/src/routes/(app)/account/savings/+page.svelte
@@ -4,7 +4,9 @@
</script>
<div class="space-y-5">
- <h1 class="text-center text-3xl font-semibold">{$t("accounts.accountSetup")}</h1>
+ <h1 class="text-center text-3xl font-semibold">
+ {$t("accounts.accountSetup")}
+ </h1>
<div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2">
<div class="space-y-5">
diff --git a/src/routes/(app)/account/setup/+page.svelte b/src/routes/(app)/account/setup/+page.svelte
index f5a5ac09..24b6e248 100644
--- a/src/routes/(app)/account/setup/+page.svelte
+++ b/src/routes/(app)/account/setup/+page.svelte
@@ -12,8 +12,7 @@
<div>
<div class="text-xl">Cash</div>
<div class="text-secondary">
- Your balance is held with a custodian. Payments are fast and
- free.
+ Your balance is held with a custodian. Payments are fast and free.
</div>
</div>
</div>
diff --git a/src/routes/(app)/admin/+page.server.ts b/src/routes/(app)/admin/+page.server.ts
index 96a1cd78..40c56c77 100644
--- a/src/routes/(app)/admin/+page.server.ts
+++ b/src/routes/(app)/admin/+page.server.ts
@@ -6,7 +6,7 @@ export async function load({ cookies, parent }) {
if (!user) redirect(307, "/login");
let users = (await get("/users", auth(cookies))).sort(
- (a, b) => b.balance - a.balance
+ (a, b) => b.balance - a.balance,
);
return { users };
}
diff --git a/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte b/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
index 89de4b58..f9c80329 100644
--- a/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
+++ b/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
@@ -34,10 +34,10 @@
{/if}
<div class="text-center text-xl">
- <span class="capitalize">{$t("payments.from")}</span> <span class="text-secondary">{mint}</span>
+ <span class="capitalize">{$t("payments.from")}</span>
+ <span class="text-secondary">{mint}</span>
</div>
-
{#if spent > 0}
<div class="text-center font-bold text-2xl">
<div>
diff --git a/src/routes/(app)/ecash/[id]/[...version]/swap/+page.server.ts b/src/routes/(app)/ecash/[id]/[...version]/swap/+page.server.ts
index c8806bf0..14e4767d 100644
--- a/src/routes/(app)/ecash/[id]/[...version]/swap/+page.server.ts
+++ b/src/routes/(app)/ecash/[id]/[...version]/swap/+page.server.ts
@@ -1,3 +1,3 @@
- export async function load() {
+export async function load() {
return { test: 123 };
}
diff --git a/src/routes/(app)/ecash/[id]/[...version]/swap/+page.svelte b/src/routes/(app)/ecash/[id]/[...version]/swap/+page.svelte
index 3df9504d..ee22cea2 100644
--- a/src/routes/(app)/ecash/[id]/[...version]/swap/+page.svelte
+++ b/src/routes/(app)/ecash/[id]/[...version]/swap/+page.svelte
@@ -2,4 +2,6 @@
export let data;
</script>
-<div class="text-center">Support for swapping in cash from other mints is coming soon</div>
+<div class="text-center">
+ Support for swapping in cash from other mints is coming soon
+</div>
diff --git a/src/routes/(app)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts
index fa644eb9..5f3c38d3 100644
--- a/src/routes/(app)/invoice/+page.server.ts
+++ b/src/routes/(app)/invoice/+page.server.ts
@@ -5,7 +5,7 @@ import type { Invoice } from "$lib/types";
export let load = async ({ cookies, parent }) => {
let aid = cookies.get("aid");
let { subject, user, rates } = await parent();
- if (aid === user.id) redirect(307, `/${user.username}/receive`)
+ if (aid === user.id) redirect(307, `/${user.username}/receive`);
let invoice: Invoice = {
aid,
diff --git a/src/routes/(app)/invoice/+server.ts b/src/routes/(app)/invoice/+server.ts
index 5e3d0300..0b5eb04e 100644
--- a/src/routes/(app)/invoice/+server.ts
+++ b/src/routes/(app)/invoice/+server.ts
@@ -1,7 +1,7 @@
import { auth, post } from "$lib/utils";
import { json } from "@sveltejs/kit";
-export let POST = async ({ cookies: c, request: r }) => {
- let j = await r.json();
- return json(await post("/invoice", j, auth(c)));
+export const POST = async ({ cookies: c, request: r }) => {
+ const j = await r.json();
+ return json(await post("/invoice", j, auth(c)));
};
diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte
index 5495e118..1a32b5b4 100644
--- a/src/routes/(app)/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/+page.svelte
@@ -52,7 +52,7 @@
user: { username, currency },
} = invoice);
- if (browser && !subbed[id])
+ if (browser && !subbed[id])
send("subscribe", invoice)
.then(() => (subbed[id] = true))
.catch((e) => {
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
index 97f148d1..f5a1b220 100644
--- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts
+++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
@@ -3,12 +3,11 @@ import invoice from "$lib/invoice";
import { redirect } from "@sveltejs/kit";
export async function load({ parent }) {
- let rates = await get("/rates");
+ let rates = await get("/rates");
let { invoice } = await parent();
- if (!invoice.amount)
- redirect(307, `/invoice/${invoice.id}`);
+ if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`);
- return { rates}
+ return { rates };
}
export const actions = {
diff --git a/src/routes/(app)/ln/[lnurl]/+page.server.ts b/src/routes/(app)/ln/[lnurl]/+page.server.ts
index cae220bf..4ac55e44 100644
--- a/src/routes/(app)/ln/[lnurl]/+page.server.ts
+++ b/src/routes/(app)/ln/[lnurl]/+page.server.ts
@@ -24,9 +24,8 @@ export const actions = {
pay: async ({ fetch, request }) => {
let error;
- let { callback, amount, minSendable, maxSendable, comment } = await fd(
- request
- );
+ let { callback, amount, minSendable, maxSendable, comment } =
+ await fd(request);
minSendable = Math.round(minSendable / 1000);
maxSendable = Math.round(maxSendable / 1000);
diff --git a/src/routes/(app)/messages/+page.server.ts b/src/routes/(app)/messages/+page.server.ts
index 94659621..a7195b18 100644
--- a/src/routes/(app)/messages/+page.server.ts
+++ b/src/routes/(app)/messages/+page.server.ts
@@ -10,7 +10,7 @@ interface Note {
seen: number;
}
-export async function load({ params, parent, }) {
+export async function load({ params, parent }) {
let { user } = await parent();
if (user.username !== params.username) redirect(307, `/${params.username}`);
let { since = 0 } = params;
@@ -22,7 +22,9 @@ export async function load({ params, parent, }) {
let { pubkey } = user;
try {
messages = await get(`/${pubkey}/${since}/messages`);
- messages = messages.sort((a: Message, b: Message) => b.created_at - a.created_at);
+ messages = messages.sort(
+ (a: Message, b: Message) => b.created_at - a.created_at,
+ );
} catch (e) {
console.log(`failed to fetch nostr messages`, e);
}
diff --git a/src/routes/(app)/messages/[recipient]/+page.server.ts b/src/routes/(app)/messages/[recipient]/+page.server.ts
index 6be9f6ec..0ff2885e 100644
--- a/src/routes/(app)/messages/[recipient]/+page.server.ts
+++ b/src/routes/(app)/messages/[recipient]/+page.server.ts
@@ -13,7 +13,8 @@ export async function load({ params, parent }) {
messages = messages
.filter(
- (m: Message) => m.recipient?.id === recipient.id || m.author?.id === recipient.id
+ (m: Message) =>
+ m.recipient?.id === recipient.id || m.author?.id === recipient.id,
)
.sort((a, b) => a.created_at - b.created_at);
} catch (e) {
diff --git a/src/routes/(app)/messages/[recipient]/+page.svelte b/src/routes/(app)/messages/[recipient]/+page.svelte
index 98638389..9b9f6f47 100644
--- a/src/routes/(app)/messages/[recipient]/+page.svelte
+++ b/src/routes/(app)/messages/[recipient]/+page.svelte
@@ -17,7 +17,7 @@
function fadeScale(
node,
- { delay = 0, duration = 200, easing = (x) => x, baseScale = 0 }
+ { delay = 0, duration = 200, easing = (x) => x, baseScale = 0 },
) {
const o = +getComputedStyle(node).opacity;
const m = getComputedStyle(node).transform.match(/scale\(([0-9.]+)\)/);
@@ -43,8 +43,8 @@
let initialize = async (p) => {
await Promise.all(
messages.map(
- async (event) => (event.message = await decrypt({ event, user }))
- )
+ async (event) => (event.message = await decrypt({ event, user })),
+ ),
);
messages = messages;
diff --git a/src/routes/(app)/otpsecret/+server.ts b/src/routes/(app)/otpsecret/+server.ts
index 2539ba27..9102dd51 100644
--- a/src/routes/(app)/otpsecret/+server.ts
+++ b/src/routes/(app)/otpsecret/+server.ts
@@ -8,7 +8,7 @@ export async function POST({ cookies, request }) {
let { username, secret } = await post("/otpsecret", body, auth(cookies));
let uri = `otpauth://totp/coinos:${username}?secret=${secret}&period=30&digits=6&algorithm=SHA1&issuer=coinos`;
return new Response(
- JSON.stringify({ secret, uri, qr: Qr.drawImg(uri, { size: 600 }) })
+ JSON.stringify({ secret, uri, qr: Qr.drawImg(uri, { size: 600 }) }),
);
} catch (e: any) {
if (e.message.includes("pin")) throw e;
diff --git a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
index 93100ff0..61809cf7 100644
--- a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
+++ b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
@@ -5,7 +5,7 @@ export async function load({ cookies, params, parent }) {
let { username } = params;
let { rates, user } = await parent();
- if ((user?.username === username)) error(500, "Cannot send to self");
+ if (user?.username === username) error(500, "Cannot send to self");
let subject = await get(`/users/${username}`);
let [amount, currency] = params.amount.split("/");
@@ -28,7 +28,7 @@ export async function load({ cookies, params, parent }) {
},
user: { username },
},
- auth(cookies)
+ auth(cookies),
);
redirect(307, `/invoice/${id}`);
diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte
index be2ba3bb..e781409f 100644
--- a/src/routes/(app)/payments/[...page]/+page.svelte
+++ b/src/routes/(app)/payments/[...page]/+page.svelte
@@ -46,7 +46,7 @@
$: selection = start
? presets.findIndex(
- (p) => Math.abs(differenceInDays(new Date(start * 1000), p.start)) < 1
+ (p) => Math.abs(differenceInDays(new Date(start * 1000), p.start)) < 1,
)
: 0;
diff --git a/src/routes/(app)/qr/[text]/+page.svelte b/src/routes/(app)/qr/[text]/+page.svelte
index 5469c084..e073b66e 100644
--- a/src/routes/(app)/qr/[text]/+page.svelte
+++ b/src/routes/(app)/qr/[text]/+page.svelte
@@ -10,13 +10,13 @@
<Qr {src} />
<button
- type="button"
- class="flex gap-2 text-center break-all rounded-2xl hover:opacity-80 py-5 px-6 w-full mx-auto justify-center border text-xl hover:bg-slate-100"
- on:click={() => copy(text)}
- >
- <Icon icon="copy" style="w-8" />
- <div class="my-auto">
- {text}
- </div>
+ type="button"
+ class="flex gap-2 text-center break-all rounded-2xl hover:opacity-80 py-5 px-6 w-full mx-auto justify-center border text-xl hover:bg-slate-100"
+ on:click={() => copy(text)}
+ >
+ <Icon icon="copy" style="w-8" />
+ <div class="my-auto">
+ {text}
+ </div>
</button>
</div>
diff --git a/src/routes/(app)/receive/[...token]/+page.server.ts b/src/routes/(app)/receive/[...token]/+page.server.ts
index 011ffb00..65888ff4 100644
--- a/src/routes/(app)/receive/[...token]/+page.server.ts
+++ b/src/routes/(app)/receive/[...token]/+page.server.ts
@@ -1,4 +1,4 @@
-import { fd} from "$lib/utils";
+import { fd } from "$lib/utils";
import { fail, redirect } from "@sveltejs/kit";
import parse from "$lib/parse";
@@ -11,7 +11,7 @@ export async function load({ params, parent, url }) {
export const actions = {
default: async ({ request, url }) => {
let { text } = await fd(request);
- await parse(text, url.host );
- return fail(400, { error: "default" });
+ await parse(text, url.host);
+ return fail(400, { error: "default" });
},
};
diff --git a/src/routes/(app)/send/[...text]/+page.server.ts b/src/routes/(app)/send/[...text]/+page.server.ts
index 950a2c98..906d6563 100644
--- a/src/routes/(app)/send/[...text]/+page.server.ts
+++ b/src/routes/(app)/send/[...text]/+page.server.ts
@@ -13,7 +13,7 @@ export async function load({ cookies, params, url }) {
export const actions = {
default: async ({ request, url }) => {
let { text } = await fd(request);
- await parse(text, url.host);
+ await parse(text, url.host);
return fail(400, { error: "default" });
},
};
diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte
index 2fbd8d59..d27df639 100644
--- a/src/routes/(app)/send/[...text]/+page.svelte
+++ b/src/routes/(app)/send/[...text]/+page.svelte
@@ -18,7 +18,8 @@
let el, text, pasted, w;
- let keypress = (e) => e.key === "Enter" ? (e.preventDefault() || el.click()) : (pasted = false);
+ let keypress = (e) =>
+ e.key === "Enter" ? e.preventDefault() || el.click() : (pasted = false);
let paste = async () => {
text = await navigator.clipboard.readText();
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
index e46a9f56..77fd8a4d 100644
--- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
+++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.ts
@@ -8,7 +8,7 @@ export async function load({ params: { address, amount, feeRate }, cookies }) {
let { fee, fees, inputs, ourfee, hex } = await post(
"/bitcoin/fee",
{ address, amount, feeRate, aid },
- auth(cookies)
+ auth(cookies),
);
let account = await get(`/account/${aid}`, auth(cookies));
diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte
index 01f41d34..132874a0 100644
--- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte
+++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte
@@ -36,14 +36,14 @@
amount < 100
? amount * 5
: amount < 1000
- ? amount
- : amount < 10000
- ? amount * 0.5
- : amount < 100000
- ? amount * 0.1
- : amount < 1000000
- ? amount * 0.05
- : amount * 0.01
+ ? amount
+ : amount < 10000
+ ? amount * 0.5
+ : amount < 100000
+ ? amount * 0.1
+ : amount < 1000000
+ ? amount * 0.05
+ : amount * 0.01,
);
let loading;
diff --git a/src/routes/(app)/sent/[id]/+page.server.ts b/src/routes/(app)/sent/[id]/+page.server.ts
index 38d95e4e..80b1d428 100644
--- a/src/routes/(app)/sent/[id]/+page.server.ts
+++ b/src/routes/(app)/sent/[id]/+page.server.ts
@@ -2,6 +2,6 @@ import { get, auth } from "$lib/utils";
export let load = async ({ cookies, params }) => {
let { id } = params;
- let p = await get(`/payments/${id}`, auth(cookies));
+ let p = await get(`/payments/${id}`, auth(cookies));
return p;
};
diff --git a/src/routes/(app)/sent/[id]/+page.svelte b/src/routes/(app)/sent/[id]/+page.svelte
index ce2c8d6e..a71a5360 100644
--- a/src/routes/(app)/sent/[id]/+page.svelte
+++ b/src/routes/(app)/sent/[id]/+page.svelte
@@ -14,10 +14,7 @@
</script>
<div class="text-center mt-20 md:mt-0">
- <div
- class="flex w-full max-w-[200px] mx-auto py-4"
- in:scale={{ start: 0.5 }}
- >
+ <div class="flex w-full max-w-[200px] mx-auto py-4" in:scale={{ start: 0.5 }}>
<Icon icon="check" style="mx-auto" />
</div>
<h1 class="text-3xl md:text-4xl font-bold mb-6">{$t("payments.sent")}!</h1>
diff --git a/src/routes/(app)/settings/[...tab]/+page.svelte b/src/routes/(app)/settings/[...tab]/+page.svelte
index f59806d1..7ef1653d 100644
--- a/src/routes/(app)/settings/[...tab]/+page.svelte
+++ b/src/routes/(app)/settings/[...tab]/+page.svelte
@@ -87,7 +87,7 @@
try {
data.set(
"cipher",
- await reEncryptEntropy(user, data.get("password"))
+ await reEncryptEntropy(user, data.get("password")),
);
} catch (e) {
console.log("Failed to encrypt keys with new password");
@@ -98,7 +98,7 @@
if ($avatar) {
try {
let { hash } = JSON.parse(
- await upload($avatar.file, $avatar.type, $avatar.progress, token)
+ await upload($avatar.file, $avatar.type, $avatar.progress, token),
);
data.set("profile", hash);
@@ -115,7 +115,7 @@
if ($banner) {
try {
let { hash } = JSON.parse(
- await upload($banner.file, $banner.type, $banner.progress, token)
+ await upload($banner.file, $banner.type, $banner.progress, token),
);
data.set("banner", hash);
@@ -161,7 +161,7 @@
await post(
"/api/request",
{ id: user.id, email: user.email },
- auth(cookies)
+ auth(cookies),
);
warning($t("user.settings.verifying"), false);
diff --git a/src/routes/(app)/settings/[...tab]/_pos.svelte b/src/routes/(app)/settings/[...tab]/_pos.svelte
index dcfcbe44..7ccaa69f 100644
--- a/src/routes/(app)/settings/[...tab]/_pos.svelte
+++ b/src/routes/(app)/settings/[...tab]/_pos.svelte
@@ -13,7 +13,7 @@
let { currency } = user;
let rate = rates[currency];
- let fiats = Object.keys(rates).sort((a,b) => a.localeCompare(b));
+ let fiats = Object.keys(rates).sort((a, b) => a.localeCompare(b));
$: user.language = $locale;
let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click());
@@ -38,6 +38,36 @@
if (!user.threshold) user.threshold = 1000000;
if (!user.reserve) user.reserve = 100000;
let reserveEl, thresholdEl;
+
+ let subscription;
+ $: updateNotifications(user.push);
+ let updateNotifications = async (push) => {
+ if (push && navigator.serviceWorker) {
+ const VAPID_PUBLIC_KEY =
+ "BEfgMDTeAn1F8ZQUGC6v5iKTD86zYXaa3QVr1E-ylKXC5c24JplcfSAN9PDlXAsVtUd3cU6j4-LsX_TKQzz_yDQ";
+
+ const swRegistration = await navigator.serviceWorker.getRegistration();
+ const pushManager = swRegistration.pushManager;
+ if (!isPushManagerActive(pushManager)) {
+ console.log("not active");
+ return;
+ }
+ subscription = await pushManager.subscribe({
+ userVisibleOnly: true,
+ applicationServerKey: VAPID_PUBLIC_KEY,
+ });
+ }
+ };
+
+ function isPushManagerActive(pushManager) {
+ if (pushManager) return true;
+
+ if (!window.navigator.standalone) {
+ console.log("not standalone");
+ }
+
+ return false;
+ }
</script>
<div>
@@ -74,6 +104,18 @@
<div>
<div class="flex justify-between items-center">
+ <span class="font-bold">{$t("user.settings.pushNotifications")}</span>
+ <Toggle id="push" bind:value={user.push} />
+ </div>
+ <p class="text-secondary mt-1 w-9/12">
+ {$t("user.settings.pushNotificationsDesc")}
+ </p>
+</div>
+
+{JSON.stringify(subscription)}
+
+<div>
+ <div class="flex justify-between items-center">
<span class="font-bold">{$t("user.settings.tipPrompt")}</span>
<Toggle id="prompt" bind:value={user.prompt} />
</div>
diff --git a/src/routes/(app)/subscription/+server.ts b/src/routes/(app)/subscription/+server.ts
new file mode 100644
index 00000000..8ae3f965
--- /dev/null
+++ b/src/routes/(app)/subscription/+server.ts
@@ -0,0 +1,11 @@
+import { auth, post } from "$lib/utils";
+import { json } from "@sveltejs/kit";
+
+export async function POST({ cookies, request }) {
+ const result = await post(
+ "/subscription",
+ await request.json(),
+ auth(cookies),
+ );
+ return json(result);
+}