wip: use new storage layer

This commit is contained in:
Ren Amamiya
2023-08-15 08:29:04 +07:00
parent adca37223c
commit 6e28bcdb96
19 changed files with 182 additions and 104 deletions

View File

@@ -6,7 +6,7 @@ import { getActiveAccount } from '@libs/storage';
export function useAccount() {
const { ndk } = useNDK();
const { status, data: account } = useQuery(
['currentAccount'],
['account'],
async () => {
const account = await getActiveAccount();
console.log('account: ', account);

View File

@@ -15,7 +15,7 @@ import { nip19 } from 'nostr-tools';
import { useMemo } from 'react';
import { useNDK } from '@libs/ndk/provider';
import { updateAccount } from '@libs/storage';
import { useStorage } from '@libs/storage/provider';
import { useStronghold } from '@stores/stronghold';
@@ -24,6 +24,7 @@ import { useAccount } from '@utils/hooks/useAccount';
export function useNostr() {
const { ndk, relayUrls } = useNDK();
const { account } = useAccount();
const { db } = useStorage();
const queryClient = useQueryClient();
const privkey = useStronghold((state) => state.privkey);
@@ -74,10 +75,10 @@ export function useNostr() {
const network = [...lruNetwork.values()] as string[];
await updateAccount('follows', [...follows]);
await updateAccount('network', [...new Set([...follows, ...network])]);
await db.updateAccount('follows', [...follows]);
await db.updateAccount('network', [...new Set([...follows, ...network])]);
queryClient.invalidateQueries(['currentAccount']);
queryClient.invalidateQueries(['account']);
return { status: 'ok' };
} catch (e) {