From d3db6492d9123a213aa9f655cd1eace408ce91eb Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Fri, 15 Sep 2023 08:58:09 +0700
Subject: [PATCH] update onboarding
---
src/app.tsx | 14 -------
src/app/auth/components/user.tsx | 27 +++++++------
src/app/auth/hardReset.tsx | 7 ----
src/app/auth/import/step-3.tsx | 2 +-
src/app/auth/onboarding/step-1.tsx | 61 ++++++++++++++++--------------
src/app/auth/onboarding/step-2.tsx | 30 ++++++++++++---
src/app/auth/unlock.tsx | 18 +++++----
src/utils/hooks/useNostr.ts | 26 +++++++++++--
8 files changed, 105 insertions(+), 80 deletions(-)
delete mode 100644 src/app/auth/hardReset.tsx
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 (
-
+
-
-
-
+
+
+
{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 (
-
- );
-}
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
+