diff --git a/src/components/note/atoms/user.tsx b/src/components/note/atoms/user.tsx
index 632fe39d..44ae2d45 100644
--- a/src/components/note/atoms/user.tsx
+++ b/src/components/note/atoms/user.tsx
@@ -27,11 +27,7 @@ export const User = memo(function User({ pubkey, time }: { pubkey: string; time:
const metadata: any = JSON.parse(rawMetadata.content);
if (profile.picture === null || profile.name === null) {
setProfile(metadata);
- await db.execute(
- `INSERT OR IGNORE INTO cache_profiles (pubkey, metadata) VALUES ("${pubkey}", '${JSON.stringify(
- metadata
- )}')`
- );
+ await db.execute(`INSERT OR IGNORE INTO cache_profiles (id, metadata) VALUES ("${pubkey}", '${JSON.stringify(metadata)}')`);
} else {
return;
}
@@ -42,9 +38,7 @@ export const User = memo(function User({ pubkey, time }: { pubkey: string; time:
useEffect(() => {
const initialProfile = async () => {
- const result: any = await db.select(
- `SELECT metadata FROM cache_profiles WHERE pubkey = "${pubkey}"`
- );
+ const result: any = await db.select(`SELECT metadata FROM cache_profiles WHERE id = "${pubkey}"`);
db.close;
return result;
};
@@ -62,27 +56,15 @@ export const User = memo(function User({ pubkey, time }: { pubkey: string; time:
{profile.picture ? (
-
+
) : (
-
+
)}
-
- {profile.name ? profile.name : truncate(pubkey, 16, ' .... ')}
-
+
{profile.name ? profile.name : truncate(pubkey, 16, ' .... ')}
ยท
{time}
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index cd066c79..06993360 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -35,14 +35,14 @@ export default function Page() {
}, []);
const getAccount = useCallback(async () => {
- const result = await db.select(`SELECT id FROM accounts ASC LIMIT 1`);
+ const result = await db.select(`SELECT * FROM accounts ASC LIMIT 1`);
return result;
}, []);
const getFollows = useCallback(async (account) => {
const arr = [];
- const result: any = await db.select(`SELECT pubkey FROM follows WHERE account = "${account.pubkey}"`);
+ const result: any = await db.select(`SELECT pubkey FROM follows WHERE account = "${account.id}"`);
result.forEach((item: { pubkey: string }) => {
arr.push(item.pubkey);
@@ -59,7 +59,6 @@ export default function Page() {
requestNotification().then(() => {
getAccount()
.then((res: any) => {
- console.log(res);
if (res.length === 0) {
setTimeout(() => {
setLoading(false);
diff --git a/src/pages/onboarding/create.tsx b/src/pages/onboarding/create.tsx
index 2034edce..01043ce4 100644
--- a/src/pages/onboarding/create.tsx
+++ b/src/pages/onboarding/create.tsx
@@ -43,12 +43,8 @@ export default function Page() {
const [privKey] = useState(() => generatePrivateKey());
const [name] = useState(() => uniqueNamesGenerator(config).toString());
- const [avatar] = useState(
- () => defaultAvatars[Math.floor(Math.random() * defaultAvatars.length)]
- );
- const [banner] = useState(
- () => defaultBanners[Math.floor(Math.random() * defaultBanners.length)]
- );
+ const [avatar] = useState(() => defaultAvatars[Math.floor(Math.random() * defaultAvatars.length)]);
+ const [banner] = useState(() => defaultBanners[Math.floor(Math.random() * defaultBanners.length)]);
const pubKey = getPublicKey(privKey);
const npub = nip19.npubEncode(pubKey);
@@ -81,9 +77,7 @@ export default function Page() {
// save account to database
const db = await Database.load('sqlite:lume.db');
await db.execute(
- `INSERT INTO accounts (privkey, pubkey, npub, nsec, current, metadata) VALUES ("${privKey}", "${pubKey}", "${npub}", "${nsec}", "1", '${JSON.stringify(
- data
- )}')`
+ `INSERT INTO accounts (id, privkey, npub, nsec, metadata) VALUES ("${pubKey}", "${privKey}", "${npub}", "${nsec}", '${JSON.stringify(data)}')`
);
await db.close();
@@ -115,14 +109,12 @@ export default function Page() {
{/* spacer */}
-
+
Create new key
- Lume will generate key with default profile for you, you can edit it later, and please
- store your key safely so you can restore your account or use other client
+ Lume will generate key with default profile for you, you can edit it later, and please store your key safely so you can restore your
+ account or use other client
@@ -145,9 +137,7 @@ export default function Page() {
value={nsec}
className="relative w-full rounded-lg border border-black/5 px-3.5 py-2 shadow-input shadow-black/5 !outline-none placeholder:text-zinc-400 dark:bg-zinc-800 dark:text-zinc-200 dark:shadow-black/10 dark:placeholder:text-zinc-600"
/>
- showNsec()}
- className="group absolute right-2 top-1/2 -translate-y-1/2 transform rounded p-1 hover:bg-zinc-700">
+ showNsec()} className="group absolute right-2 top-1/2 -translate-y-1/2 transform rounded p-1 hover:bg-zinc-700">
{type === 'password' ? (
) : (
@@ -157,19 +147,12 @@ export default function Page() {
-
- Default Profile (you can change it later)
-
+
Default Profile (you can change it later)
-
+
@@ -193,18 +176,8 @@ export default function Page() {
{loading === true ? (
-
-
+
+
>
- | ReactFragment
- | ReactPortal
+ page: string | number | boolean | ReactElement> | ReactFragment | ReactPortal
) {
return (
diff --git a/src/pages/onboarding/fetch-follows.tsx b/src/pages/onboarding/fetch-follows.tsx
index 2088f7f2..335aea3f 100644
--- a/src/pages/onboarding/fetch-follows.tsx
+++ b/src/pages/onboarding/fetch-follows.tsx
@@ -5,14 +5,7 @@ import OnboardingLayout from '@layouts/onboardingLayout';
import { motion } from 'framer-motion';
import { useRouter } from 'next/router';
import { useNostrEvents } from 'nostr-react';
-import {
- JSXElementConstructor,
- ReactElement,
- ReactFragment,
- ReactPortal,
- useEffect,
- useState,
-} from 'react';
+import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useEffect, useState } from 'react';
import Database from 'tauri-plugin-sql-api';
export default function Page() {
@@ -44,9 +37,7 @@ export default function Page() {
const db = await Database.load('sqlite:lume.db');
follows.forEach(async (item) => {
if (item) {
- await db.execute(
- `INSERT OR IGNORE INTO follows (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`
- );
+ await db.execute(`INSERT OR IGNORE INTO follows (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`);
}
});
};
@@ -68,32 +59,19 @@ export default function Page() {
{/* spacer */}
-
+
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)
+ 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 ? (
-
-
+
+
>
- | ReactFragment
- | ReactPortal
+ page: string | number | boolean | ReactElement> | ReactFragment | ReactPortal
) {
return (
diff --git a/src/pages/onboarding/fetch-profile.tsx b/src/pages/onboarding/fetch-profile.tsx
index fc3c5d54..031e17f0 100644
--- a/src/pages/onboarding/fetch-profile.tsx
+++ b/src/pages/onboarding/fetch-profile.tsx
@@ -6,14 +6,7 @@ import { motion } from 'framer-motion';
import { useRouter } from 'next/router';
import { useNostrEvents } from 'nostr-react';
import { getPublicKey, nip19 } from 'nostr-tools';
-import {
- JSXElementConstructor,
- ReactElement,
- ReactFragment,
- ReactPortal,
- useEffect,
- useState,
-} from 'react';
+import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useCallback, useEffect, useState } from 'react';
import Database from 'tauri-plugin-sql-api';
export default function Page() {
@@ -43,20 +36,19 @@ export default function Page() {
}
});
+ const insertDB = useCallback(async () => {
+ // save account to database
+ const db = await Database.load('sqlite:lume.db');
+ const metadata = JSON.stringify(account);
+ await db.execute(
+ `INSERT INTO accounts (id, privkey, npub, nsec, metadata) VALUES ("${pubkey}", "${privkey}", "${npub}", "${nsec}", '${metadata}')`
+ );
+ await db.close();
+ }, [account, npub, nsec, privkey, pubkey]);
+
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, current, metadata) VALUES ("${privkey}", "${pubkey}", "${npub}", "${nsec}", "1", '${JSON.stringify(
- account
- )}')`
- );
- await db.close();
- };
-
if (account !== null) {
insertDB()
.then(() => {
@@ -70,39 +62,26 @@ export default function Page() {
})
.catch(console.error);
}
- }, [account, npub, nsec, privkey, pubkey, router]);
+ }, [account, insertDB, npub, nsec, privkey, pubkey, router]);
return (
{/* spacer */}
-
+
Fetching your profile...
- As long as you have private key, you alway can sync your profile on every nostr client,
- so please keep your key safely
+ As long as you have private key, you alway can sync your profile on every nostr client, so please keep your key safely
{loading === true ? (
-
-
+
+
>
- | ReactFragment
- | ReactPortal
+ page: string | number | boolean | ReactElement> | ReactFragment | ReactPortal
) {
return (
diff --git a/src/pages/onboarding/following.tsx b/src/pages/onboarding/following.tsx
index e9a60993..2d5e8cef 100644
--- a/src/pages/onboarding/following.tsx
+++ b/src/pages/onboarding/following.tsx
@@ -33,14 +33,11 @@ export default function Page() {
const insertDB = async () => {
const db = await Database.load('sqlite:lume.db');
- await db.execute(
- `INSERT INTO follows (pubkey, account) VALUES ("${$currentUser.pubkey}", "${$currentUser.pubkey}")`
- );
+ // self followed
+ await db.execute(`INSERT INTO follows (pubkey, account) VALUES ("${$currentUser.pubkey}", "${$currentUser.pubkey}")`);
follow.forEach(async (npub) => {
const { data } = nip19.decode(npub);
- await db.execute(
- `INSERT INTO follows (pubkey, account) VALUES ("${data}", "${$currentUser.pubkey}")`
- );
+ await db.execute(`INSERT INTO follows (pubkey, account) VALUES ("${data}", "${$currentUser.pubkey}")`);
});
};
@@ -60,14 +57,11 @@ export default function Page() {
{/* spacer */}
-
+
Choose 10 people you want to following
- For better experiences, you should follow the people you care about to personalize your
- newsfeed, otherwise you will be very bored
+ For better experiences, you should follow the people you care about to personalize your newsfeed, otherwise you will be very bored
@@ -81,27 +75,14 @@ export default function Page() {
follow.includes(item.npub) ? 'bg-zinc-800' : ''
}`}>
-
+
{item.name}
-
- {truncate(item.npub, 16, ' .... ')}
-
-
-
- {follow.includes(item.npub) ? (
-
- ) : (
- <>>
- )}
+
{truncate(item.npub, 16, ' .... ')}
+
{follow.includes(item.npub) ? : <>>}
))}
@@ -111,18 +92,8 @@ export default function Page() {
{loading === true ? (
-
-
+
+
>
- | ReactFragment
- | ReactPortal
+ page: string | number | boolean | ReactElement> | ReactFragment | ReactPortal
) {
return (
diff --git a/src/pages/onboarding/import.tsx b/src/pages/onboarding/import.tsx
index a3e9604b..454fae06 100644
--- a/src/pages/onboarding/import.tsx
+++ b/src/pages/onboarding/import.tsx
@@ -60,14 +60,12 @@ export default function Page() {
{/* spacer */}
-
+
Import your private key
- You can import private key format as hex string or nsec. If you have installed Nostr
- Connect compality wallet in your mobile, you can connect by scan QR Code below
+ You can import private key format as hex string or nsec. If you have installed Nostr Connect compality wallet in your mobile, you can
+ connect by scan QR Code below
@@ -85,18 +83,8 @@ export default function Page() {
{isSubmitting ? (
-
-
+
+
>
- | ReactFragment
- | ReactPortal
+ page: string | number | boolean | ReactElement> | ReactFragment | ReactPortal
) {
return (