diff --git a/src/lib/store.svelte.ts b/src/lib/store.svelte.ts index 5986bd9..3e6f5c3 100644 --- a/src/lib/store.svelte.ts +++ b/src/lib/store.svelte.ts @@ -53,6 +53,7 @@ class NewsStore { lastStatusCheck = $state(Date.now()); authInfo = $state<{ required: boolean; mode: string; canReg: boolean } | null>(null); isAuthenticated = $state(false); + newlyRegisteredToken = $state(null); isWails = typeof window !== 'undefined' && ((window as any).runtime || (window as any).go); isCapacitor = typeof window !== 'undefined' && Capacitor.isNativePlatform(); @@ -185,7 +186,7 @@ class NewsStore { const response = await fetch(`${apiBase}/auth/register`, { method: 'POST' }); if (!response.ok) throw new Error('Registration failed'); const data = await response.json(); - await this.login(data.accountNumber); + this.newlyRegisteredToken = data.accountNumber; return data.accountNumber; } catch { toast.error('Could not generate account'); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 25e0e75..6ec808b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -20,6 +20,8 @@ X, Hash, ChevronRight, + Copy, + Check, } from 'lucide-svelte'; import { db } from '$lib/db'; import { toast } from '$lib/toast.svelte'; @@ -115,6 +117,18 @@ let isResizing = $state(false); let paneWidth = $state(newsStore.settings.paneWidth || 40); let showDismissHatch = $state(false); + let copied = $state(false); + + async function copyToClipboard(text: string) { + try { + await navigator.clipboard.writeText(text); + copied = true; + setTimeout(() => (copied = false), 2000); + toast.success('Account number copied to clipboard'); + } catch { + toast.error('Failed to copy'); + } + } function startResizing(e: MouseEvent) { e.preventDefault(); @@ -280,62 +294,118 @@
-
-
- -
-

Welcome to Web News

-

Please enter your account number to continue

-
+ {#if newsStore.newlyRegisteredToken} +
+
+ +
+

Account Created!

+

+ Save your account number now. You will need it to log back in.
+ We cannot recover this for you. +

-
-
- -
- - e.key === 'Enter' && newsStore.login(loginToken)} - /> +
+ + +
+ +
+ +
+ {:else} +
+
+ +
+

Welcome to Web News

+

Please enter your account number to continue

+
- - - {#if newsStore.authInfo?.canReg} -
-
-
-
-
- Or +
+
+ +
+ + e.key === 'Enter' && newsStore.login(loginToken)} + />
- {/if} -
+ + {#if newsStore.authInfo?.canReg} +
+
+
+
+
+ Or +
+
+ + + {/if} +
+ {/if}

Web News is privacy-focused. We don't use emails or passwords.
diff --git a/src/routes/share/+page.svelte b/src/routes/share/+page.svelte index 3c7a8ad..c8c1324 100644 --- a/src/routes/share/+page.svelte +++ b/src/routes/share/+page.svelte @@ -64,12 +64,18 @@ {article ? article.title : 'Shared Article on Webnews'} - - + + - + {#if article?.imageUrl} {:else} @@ -79,7 +85,10 @@ - + {#if article?.imageUrl} {:else}