wip: replace ndk cache with metadata table

This commit is contained in:
Ren Amamiya
2023-09-21 16:11:35 +07:00
parent 413571ee7f
commit 18a9ba3fb0
5 changed files with 61 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
// inspire by: https://github.com/nostr-dev-kit/ndk-react/
import NDK from '@nostr-dev-kit/ndk';
import { ndkAdapter } from '@nostr-fetch/adapter-ndk';
import { message } from '@tauri-apps/api/dialog';
@@ -6,7 +5,6 @@ import { fetch } from '@tauri-apps/api/http';
import { NostrFetcher } from 'nostr-fetch';
import { useEffect, useMemo, useState } from 'react';
import TauriAdapter from '@libs/ndk/cache';
import { useStorage } from '@libs/storage/provider';
export const NDKInstance = () => {
@@ -15,7 +13,6 @@ export const NDKInstance = () => {
const [ndk, setNDK] = useState<NDK | undefined>(undefined);
const [relayUrls, setRelayUrls] = useState<string[]>([]);
const cacheAdapter = useMemo(() => new TauriAdapter(), [ndk]);
const fetcher = useMemo(
() => (ndk ? NostrFetcher.withCustomPool(ndkAdapter(ndk)) : null),
[ndk]
@@ -61,7 +58,6 @@ export const NDKInstance = () => {
const explicitRelayUrls = await getExplicitRelays();
const instance = new NDK({
explicitRelayUrls,
cacheAdapter,
});
try {
@@ -79,10 +75,6 @@ export const NDKInstance = () => {
useEffect(() => {
if (!ndk) initNDK();
return () => {
cacheAdapter.saveCache();
};
}, []);
return {