polish
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useNDK } from '@libs/ndk/provider';
|
||||
import { getActiveAccount } from '@libs/storage';
|
||||
|
||||
export function useAccount() {
|
||||
const { ndk } = useNDK();
|
||||
const { status, data: account } = useQuery(
|
||||
['currentAccount'],
|
||||
async () => await getActiveAccount(),
|
||||
async () => {
|
||||
const account = await getActiveAccount();
|
||||
if (account?.pubkey) {
|
||||
const user = ndk.getUser({ hexpubkey: account?.pubkey });
|
||||
await user.fetchProfile();
|
||||
return { ...account, ...user.profile };
|
||||
}
|
||||
return account;
|
||||
},
|
||||
{
|
||||
staleTime: Infinity,
|
||||
refetchOnMount: true,
|
||||
|
||||
Reference in New Issue
Block a user