added current status to user
This commit is contained in:
@@ -5,8 +5,13 @@ import { memo } from 'react';
|
||||
export const Account = memo(function Account({ user, current }: { user: any; current: string }) {
|
||||
const userData = JSON.parse(user.metadata);
|
||||
|
||||
const setCurrentUser = () => {
|
||||
console.log('clicked');
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
<button
|
||||
onClick={() => setCurrentUser()}
|
||||
className={`relative h-11 w-11 shrink overflow-hidden rounded-full ${
|
||||
current === user.pubkey ? 'ring-1 ring-fuchsia-500 ring-offset-4 ring-offset-black' : ''
|
||||
}`}>
|
||||
@@ -20,6 +25,6 @@ export const Account = memo(function Account({ user, current }: { user: any; cur
|
||||
) : (
|
||||
<div className="h-11 w-11 animate-pulse rounded-full bg-zinc-700" />
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -13,15 +13,17 @@ export default function CheckAccount() {
|
||||
useEffect(() => {
|
||||
const accounts = async () => {
|
||||
const db = await Database.load('sqlite:lume.db');
|
||||
const result = await db.select('SELECT * FROM accounts ORDER BY id ASC LIMIT 1');
|
||||
const result = await db.select(
|
||||
`SELECT * FROM accounts WHERE current = "1" ORDER BY id ASC LIMIT 1`
|
||||
);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const getFollowings = async (account) => {
|
||||
const getFollows = async (account) => {
|
||||
const db = await Database.load('sqlite:lume.db');
|
||||
const result: any = await db.select(
|
||||
`SELECT pubkey FROM followings WHERE account = "${account.pubkey}"`
|
||||
`SELECT pubkey FROM follows WHERE account = "${account.pubkey}"`
|
||||
);
|
||||
|
||||
const arr = [];
|
||||
@@ -43,7 +45,7 @@ export default function CheckAccount() {
|
||||
} else {
|
||||
currentUser.set(res[0]);
|
||||
|
||||
getFollowings(res[0])
|
||||
getFollows(res[0])
|
||||
.then(async (res) => {
|
||||
follows.set(res);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user