diff --git a/src/app.tsx b/src/app.tsx index 9c09fa2f..cdb894f6 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -205,13 +205,6 @@ const router = createBrowserRouter([ return { Component: OnboardStep2Screen }; }, }, - { - path: 'step-3', - async lazy() { - const { OnboardStep3Screen } = await import('@app/auth/onboarding/step-3'); - return { Component: OnboardStep3Screen }; - }, - }, ], }, { @@ -235,13 +228,6 @@ const router = createBrowserRouter([ return { Component: ResetScreen }; }, }, - { - path: 'hard-reset', - async lazy() { - const { HardResetScreen } = await import('@app/auth/hardReset'); - return { Component: HardResetScreen }; - }, - }, ], }, { diff --git a/src/app/auth/components/user.tsx b/src/app/auth/components/user.tsx index c4b26e9c..bfded070 100644 --- a/src/app/auth/components/user.tsx +++ b/src/app/auth/components/user.tsx @@ -11,7 +11,7 @@ export function User({ pubkey, fallback }: { pubkey: string; fallback?: string } if (status === 'loading') { return (
-
+
@@ -21,30 +21,33 @@ export function User({ pubkey, fallback }: { pubkey: string; fallback?: string } } return ( -
+
{pubkey} -
-
-

+

+
+

{user?.name || user?.display_name}

+

+ {user?.about || user?.bio || 'No bio'} +

+
+
{user?.website ? ( - {' '} + +

{user.website}

) : null}
-
- {user?.about || user?.bio || 'No bio'} -
); diff --git a/src/app/auth/hardReset.tsx b/src/app/auth/hardReset.tsx deleted file mode 100644 index c8982034..00000000 --- a/src/app/auth/hardReset.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export function HardResetScreen() { - return ( -
-

hard reset

-
- ); -} diff --git a/src/app/auth/import/step-3.tsx b/src/app/auth/import/step-3.tsx index b4769b76..59203f5e 100644 --- a/src/app/auth/import/step-3.tsx +++ b/src/app/auth/import/step-3.tsx @@ -51,7 +51,7 @@ export function ImportStep3Screen() {

- {loading ? 'Prefetching data...' : 'Your Nostr profile'} + {loading ? 'Downloading...' : 'Your Nostr profile'}

diff --git a/src/app/auth/onboarding/step-1.tsx b/src/app/auth/onboarding/step-1.tsx index f0d38d48..e788fe4d 100644 --- a/src/app/auth/onboarding/step-1.tsx +++ b/src/app/auth/onboarding/step-1.tsx @@ -68,8 +68,8 @@ export function OnboardStep1Screen() { }, []); return ( -
-
+
+

{loading ? 'Prefetching data...' : 'Enrich your network'}

@@ -79,32 +79,30 @@ export function OnboardStep1Screen() { add them later.

-
-
- {status === 'loading' ? ( -
- -
- ) : ( - data?.profiles.map( - (item: { pubkey: string; profile: { content: string } }) => ( - - ) - ) - )} -
+
+ {status === 'loading' ? ( +
+ +
+ ) : ( + data?.profiles.map((item: { pubkey: string; profile: { content: string } }) => ( + + )) + )} +
+
diff --git a/src/app/auth/onboarding/step-2.tsx b/src/app/auth/onboarding/step-2.tsx index 99467cd8..6c7dd542 100644 --- a/src/app/auth/onboarding/step-2.tsx +++ b/src/app/auth/onboarding/step-2.tsx @@ -1,6 +1,6 @@ import { message } from '@tauri-apps/api/dialog'; import { useEffect, useState } from 'react'; -import { Link, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { useStorage } from '@libs/storage/provider'; @@ -34,8 +34,8 @@ const data = [ export function OnboardStep2Screen() { const navigate = useNavigate(); - const setStep = useOnboarding((state) => state.setStep); + const [setStep, clearStep] = useOnboarding((state) => [state.setStep, state.clearStep]); const [loading, setLoading] = useState(false); const [tags, setTags] = useState(new Set()); @@ -53,6 +53,16 @@ export function OnboardStep2Screen() { } }; + const skip = async () => { + // update last login + await db.updateLastLogin(); + + // clear local storage + clearStep(); + + navigate('/', { replace: true }); + }; + const submit = async () => { try { setLoading(true); @@ -61,8 +71,15 @@ export function OnboardStep2Screen() { await db.createWidget(WidgetKinds.global.hashtag, tag, tag.replace('#', '')); } - navigate('/auth/onboarding/step-3', { replace: true }); + // update last login + await db.updateLastLogin(); + + // clear local storage + clearStep(); + + navigate('/', { replace: true }); } catch (e) { + setLoading(false); await message(e, { title: 'Lume', type: 'error' }); } }; @@ -123,12 +140,13 @@ export function OnboardStep2Screen() { )} {!loading ? ( - skip()} className="inline-flex h-12 w-full items-center justify-center rounded-lg border-t border-white/10 bg-white/20 font-medium leading-none text-white backdrop-blur-xl hover:bg-white/30 focus:outline-none" > Skip, you can add later - + ) : null}
diff --git a/src/app/auth/unlock.tsx b/src/app/auth/unlock.tsx index 95609c5a..84d770b2 100644 --- a/src/app/auth/unlock.tsx +++ b/src/app/auth/unlock.tsx @@ -4,7 +4,7 @@ import { Resolver, useForm } from 'react-hook-form'; import { Link, useNavigate } from 'react-router-dom'; import { Stronghold } from 'tauri-plugin-stronghold-api'; -import { User } from '@app/auth/components/user'; +import { UserImport } from '@app/auth/components/userImport'; import { useStorage } from '@libs/storage/provider'; @@ -74,20 +74,22 @@ export function UnlockScreen() { return (
-
-

Enter password to unlock

+
+

+ Enter password to unlock +

- +
Reset password diff --git a/src/utils/hooks/useNostr.ts b/src/utils/hooks/useNostr.ts index 57ce9438..627da89f 100644 --- a/src/utils/hooks/useNostr.ts +++ b/src/utils/hooks/useNostr.ts @@ -57,6 +57,24 @@ export function useNostr() { const follows = new Set(preFollows || []); const lruNetwork = new LRUCache({ max: 300 }); + // fetch user's relays + const relayEvents = await ndk.fetchEvents({ + kinds: [NDKKind.RelayList], + authors: [db.account.pubkey], + }); + + if (relayEvents) { + const latestRelayEvent = [...relayEvents].sort( + (a, b) => b.created_at - a.created_at + )[0]; + + if (latestRelayEvent) { + for (const item of latestRelayEvent.tags) { + await db.createRelay(item[1], item[2]); + } + } + } + // fetch user's follows if (!preFollows) { const user = ndk.getUser({ hexpubkey: db.account.pubkey }); @@ -67,20 +85,22 @@ export function useNostr() { } // build user's network - const events = await ndk.fetchEvents({ - kinds: [3], + const followEvents = await ndk.fetchEvents({ + kinds: [NDKKind.Contacts], authors: [...follows], limit: 300, }); - events.forEach((event: NDKEvent) => { + followEvents.forEach((event: NDKEvent) => { event.tags.forEach((tag) => { if (tag[0] === 'p') lruNetwork.set(tag[1], tag[1]); }); }); + // get lru values const network = [...lruNetwork.values()] as string[]; + // update db await db.updateAccount('follows', [...follows]); await db.updateAccount('network', [...new Set([...follows, ...network])]);