diff --git a/src/App.tsx b/src/App.tsx index 95183ab..fc48012 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,12 @@ import { RouterProvider } from 'react-router-dom' -import { useEffect } from 'react' -import { routerWithNdkContext } from 'routes' +import { useEffect, useMemo } from 'react' +import { routerWithNdkContext as routerWithState } from 'routes' import { useNDKContext } from 'hooks' import './styles/styles.css' function App() { const ndkContext = useNDKContext() + const router = useMemo(() => routerWithState(ndkContext), [ndkContext]) useEffect(() => { // Find the element with id 'root' @@ -24,7 +25,7 @@ function App() { } }, []) - return + return } export default App diff --git a/src/layout/index.tsx b/src/layout/index.tsx index f936f04..cdddc70 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -44,7 +44,7 @@ export const Layout = () => { }) } } - }, [ndk, dispatch]) + }, [dispatch, ndk]) // calculate user's wot useEffect(() => { @@ -60,7 +60,7 @@ export const Layout = () => { toast.error('An error occurred in calculating user web-of-trust!') }) } - }, [ndk, userState.user, dispatch]) + }, [dispatch, ndk, userState.user?.pubkey]) // get site's wot level useEffect(() => { @@ -106,7 +106,7 @@ export const Layout = () => { }) } } - }, [userState.user, dispatch, fetchEventFromUserRelays]) + }, [dispatch, fetchEventFromUserRelays, userState.user?.pubkey]) return ( <> diff --git a/src/utils/nostr.ts b/src/utils/nostr.ts index 772c37b..47ab343 100644 --- a/src/utils/nostr.ts +++ b/src/utils/nostr.ts @@ -274,3 +274,16 @@ export function orderEventsChronologically( return events } + +/** + * Receives two events and returns the "correct" event to use. + * #nip-33 + */ +export default function dedup(event1: NDKEvent, event2: NDKEvent) { + // return the newest of the two + if (event1.created_at! > event2.created_at!) { + return event1 + } + + return event2 +}