2024-10-14 13:24:43 +05:00
|
|
|
import { NDKContext } from 'contexts/NDKContext'
|
|
|
|
import { useContext } from 'react'
|
|
|
|
|
|
|
|
export const useNDKContext = () => {
|
|
|
|
const ndkContext = useContext(NDKContext)
|
|
|
|
|
|
|
|
if (!ndkContext)
|
|
|
|
throw new Error(
|
|
|
|
'NDKContext should not be used in out component tree hierarchy'
|
|
|
|
)
|
|
|
|
|
2024-10-14 19:20:43 +05:00
|
|
|
const {
|
|
|
|
ndk,
|
|
|
|
fetchEvents,
|
|
|
|
fetchEvent,
|
|
|
|
fetchEventsFromUserRelays,
|
|
|
|
fetchEventFromUserRelays,
|
|
|
|
fetchMods,
|
|
|
|
findMetadata
|
|
|
|
} = ndkContext
|
2024-10-14 13:24:43 +05:00
|
|
|
|
|
|
|
return {
|
|
|
|
ndk,
|
|
|
|
fetchEvents,
|
2024-10-14 19:20:43 +05:00
|
|
|
fetchEvent,
|
|
|
|
fetchEventsFromUserRelays,
|
|
|
|
fetchEventFromUserRelays,
|
|
|
|
fetchMods,
|
|
|
|
findMetadata
|
2024-10-14 13:24:43 +05:00
|
|
|
}
|
|
|
|
}
|