minor fixes

This commit is contained in:
Ren Amamiya
2023-04-11 14:07:56 +07:00
parent 4b582e33f6
commit 4729250550
3 changed files with 13 additions and 17 deletions

View File

@@ -26,7 +26,7 @@ export default function NoteMetadata({
{ {
'#e': [eventID], '#e': [eventID],
since: parseInt(eventTime), since: parseInt(eventTime),
kinds: [1, 7], kinds: [7],
limit: 50, limit: 50,
}, },
], ],
@@ -48,11 +48,7 @@ export default function NoteMetadata({
break; break;
} }
}, },
1000, 1000
undefined,
{
unsubscribeOnEose: true,
}
); );
return () => { return () => {

View File

@@ -6,7 +6,7 @@ export const RelayContext = createContext({});
const relays = [ const relays = [
'wss://relay.damus.io', 'wss://relay.damus.io',
'wss://nostr-pub.wellorder.net', 'wss://nostr-pub.wellorder.net',
'wss://nostr.bongbong.com', //'wss://nostr.bongbong.com',
'wss://nostr.zebedee.cloud', 'wss://nostr.zebedee.cloud',
'wss://nostr.fmt.wiz.biz', 'wss://nostr.fmt.wiz.biz',
'wss://relay.snort.social', 'wss://relay.snort.social',

View File

@@ -1,15 +1,15 @@
import { RelayContext } from '@components/relaysProvider'; import { fetch } from '@tauri-apps/api/http';
import { useCallback, useEffect, useState } from 'react';
import { Author } from 'nostr-relaypool'; export const fetchMetadata = async (pubkey: string) => {
import { useCallback, useContext, useEffect, useState } from 'react'; const result = await fetch(`https://rbr.bio/${pubkey}/metadata.json`, {
method: 'GET',
export const fetchMetadata = (pubkey: string, pool: any, relays: any) => { timeout: 5,
const author = new Author(pool, relays, pubkey); });
return new Promise((resolve) => author.metaData(resolve, 0)); return await result.data;
}; };
export const useMetadata = (pubkey) => { export const useMetadata = (pubkey) => {
const [pool, relays]: any = useContext(RelayContext);
const [profile, setProfile] = useState(null); const [profile, setProfile] = useState(null);
const getCachedMetadata = useCallback(async () => { const getCachedMetadata = useCallback(async () => {
@@ -20,7 +20,7 @@ export const useMetadata = (pubkey) => {
const metadata = JSON.parse(res.metadata); const metadata = JSON.parse(res.metadata);
setProfile(metadata); setProfile(metadata);
} else { } else {
fetchMetadata(pubkey, pool, relays).then((res: any) => { fetchMetadata(pubkey).then((res: any) => {
if (res.content) { if (res.content) {
const metadata = JSON.parse(res.content); const metadata = JSON.parse(res.content);
setProfile(metadata); setProfile(metadata);
@@ -29,7 +29,7 @@ export const useMetadata = (pubkey) => {
} }
}) })
.catch(console.error); .catch(console.error);
}, [pool, relays, pubkey]); }, [pubkey]);
useEffect(() => { useEffect(() => {
getCachedMetadata().catch(console.error); getCachedMetadata().catch(console.error);