added current status to user
This commit is contained in:
@@ -82,7 +82,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, metadata) VALUES ("${privKey}", "${pubKey}", "${npub}", "${nsec}", '${JSON.stringify(
|
||||
`INSERT INTO accounts (privkey, pubkey, npub, nsec, current, metadata) VALUES ("${privKey}", "${pubKey}", "${npub}", "${nsec}", "1", '${JSON.stringify(
|
||||
data
|
||||
)}')`
|
||||
);
|
||||
|
||||
@@ -34,12 +34,12 @@ export default function Page() {
|
||||
const insertDB = async () => {
|
||||
const db = await Database.load('sqlite:lume.db');
|
||||
await db.execute(
|
||||
`INSERT INTO followings (pubkey, account) VALUES ("${$currentUser.pubkey}", "${$currentUser.pubkey}")`
|
||||
`INSERT INTO follows (pubkey, account) VALUES ("${$currentUser.pubkey}", "${$currentUser.pubkey}")`
|
||||
);
|
||||
follow.forEach(async (npub) => {
|
||||
const { data } = nip19.decode(npub);
|
||||
await db.execute(
|
||||
`INSERT INTO followings (pubkey, account) VALUES ("${data}", "${$currentUser.pubkey}")`
|
||||
`INSERT INTO follows (pubkey, account) VALUES ("${data}", "${$currentUser.pubkey}")`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function Page({ pubkey }: { pubkey: string }) {
|
||||
follows.forEach(async (item) => {
|
||||
if (item) {
|
||||
await db.execute(
|
||||
`INSERT INTO followings (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`
|
||||
`INSERT INTO follows (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,11 +18,11 @@ import {
|
||||
import Database from 'tauri-plugin-sql-api';
|
||||
|
||||
export default function Page({ privkey }: { privkey: string }) {
|
||||
const router = useRouter();
|
||||
|
||||
const [account, setAccount] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const pubkey = getPublicKey(privkey);
|
||||
const npub = nip19.npubEncode(pubkey);
|
||||
const nsec = nip19.nsecEncode(privkey);
|
||||
@@ -45,11 +45,12 @@ export default function Page({ privkey }: { privkey: string }) {
|
||||
|
||||
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(
|
||||
`INSERT INTO accounts (privkey, pubkey, npub, nsec, current, metadata) VALUES ("${privkey}", "${pubkey}", "${npub}", "${nsec}", "1", '${JSON.stringify(
|
||||
account
|
||||
)}')`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user