+
+ Fetching your follows...
+
+
+ Not only profile, every nostr client can sync your follows list when you move to a new
+ client, so please keep your key safely (again)
+
+
+
+
+
+ {loading === true ? (
+
+ ) : (
+ <>>
+ )}
+
+
+
+ );
+}
+
+Page.getLayout = function getLayout(
+ page:
+ | string
+ | number
+ | boolean
+ | ReactElement>
+ | ReactFragment
+ | ReactPortal
+) {
+ return (
+
+ {page}
+
+ );
+};
diff --git a/src/pages/onboarding/fetch-profile.tsx b/src/pages/onboarding/fetch-profile.tsx
index d3ba1788..befbeecc 100644
--- a/src/pages/onboarding/fetch-profile.tsx
+++ b/src/pages/onboarding/fetch-profile.tsx
@@ -11,13 +11,14 @@ import {
ReactElement,
ReactFragment,
ReactPortal,
- useCallback,
+ useEffect,
useState,
} from 'react';
import Database from 'tauri-plugin-sql-api';
export default function Page() {
const [account, setAccount] = useState(null);
+ const [loading, setLoading] = useState(false);
const router = useRouter();
const { privkey }: any = router.query;
@@ -42,19 +43,32 @@ export default function Page() {
}
});
- const insertAccount = useCallback(async () => {
- // save account to database
- const db = await Database.load('sqlite:lume.db');
- await db.execute(
- `INSERT INTO accounts (privkey, pubkey, npub, nsec, metadata) VALUES ("${privkey}", "${pubkey}", "${npub}", "${nsec}", '${JSON.stringify(
- account
- )}')`
- );
- await db.close();
+ useEffect(() => {
+ setLoading(true);
+ const insertDB = async () => {
+ // save account to database
+ const db = await Database.load('sqlite:lume.db');
+ await db.execute(
+ `INSERT INTO accounts (privkey, pubkey, npub, nsec, metadata) VALUES ("${privkey}", "${pubkey}", "${npub}", "${nsec}", '${JSON.stringify(
+ account
+ )}')`
+ );
+ await db.close();
+ };
- setTimeout(() => {
- router.push('/feed/following');
- }, 500);
+ if (account !== null) {
+ insertDB()
+ .then(() => {
+ setTimeout(() => {
+ setLoading(false);
+ router.push({
+ pathname: '/onboarding/fetch-follows',
+ query: { pubkey: pubkey },
+ });
+ }, 1500);
+ })
+ .catch(console.error);
+ }
}, [account, npub, nsec, privkey, pubkey, router]);
return (
@@ -65,26 +79,37 @@ export default function Page() {
- Getting your old profile
+ Fetching your profile...
- As long as you have private key, you alway can recover your profile as well as follows
- list when you move to new nostr client
+ As long as you have private key, you alway can sync your profile on every nostr client,
+ so please keep your key safely
-