refactor relay provider
This commit is contained in:
@@ -2,6 +2,8 @@ import { NoteMetadata } from '@components/note/metadata';
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
import { UserExtend } from '@components/user/extend';
|
||||
|
||||
import { DEFAULT_RELAYS } from '@stores/constants';
|
||||
|
||||
import { contentParser } from '@utils/parser';
|
||||
import { createNote, getNoteByID } from '@utils/storage';
|
||||
import { getParentID } from '@utils/transform';
|
||||
@@ -10,7 +12,7 @@ import useLocalStorage from '@rehooks/local-storage';
|
||||
import { memo, useCallback, useContext, useEffect, useState } from 'react';
|
||||
|
||||
export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const pool: any = useContext(RelayContext);
|
||||
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
const [event, setEvent] = useState(null);
|
||||
@@ -25,7 +27,7 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
|
||||
kinds: [1],
|
||||
},
|
||||
],
|
||||
relays,
|
||||
DEFAULT_RELAYS,
|
||||
(event: any) => {
|
||||
// update state
|
||||
setEvent(event);
|
||||
@@ -53,7 +55,7 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, [activeAccount.id, id, pool, relays]);
|
||||
}, [activeAccount.id, id, pool]);
|
||||
|
||||
const checkNoteIsSaved = useCallback(async () => {
|
||||
getNoteByID(id)
|
||||
|
||||
Reference in New Issue
Block a user