refactor: deps cleanup
This commit is contained in:
parent
4bf9787660
commit
ad3d069ad5
@ -1,11 +1,12 @@
|
|||||||
import { RouterProvider } from 'react-router-dom'
|
import { RouterProvider } from 'react-router-dom'
|
||||||
import { useEffect } from 'react'
|
import { useEffect, useMemo } from 'react'
|
||||||
import { routerWithNdkContext } from 'routes'
|
import { routerWithNdkContext as routerWithState } from 'routes'
|
||||||
import { useNDKContext } from 'hooks'
|
import { useNDKContext } from 'hooks'
|
||||||
import './styles/styles.css'
|
import './styles/styles.css'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const ndkContext = useNDKContext()
|
const ndkContext = useNDKContext()
|
||||||
|
const router = useMemo(() => routerWithState(ndkContext), [ndkContext])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Find the element with id 'root'
|
// Find the element with id 'root'
|
||||||
@ -24,7 +25,7 @@ function App() {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <RouterProvider router={routerWithNdkContext(ndkContext)} />
|
return <RouterProvider router={router} />
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
|
@ -44,7 +44,7 @@ export const Layout = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [ndk, dispatch])
|
}, [dispatch, ndk])
|
||||||
|
|
||||||
// calculate user's wot
|
// calculate user's wot
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -60,7 +60,7 @@ export const Layout = () => {
|
|||||||
toast.error('An error occurred in calculating user web-of-trust!')
|
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
|
// get site's wot level
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -106,7 +106,7 @@ export const Layout = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [userState.user, dispatch, fetchEventFromUserRelays])
|
}, [dispatch, fetchEventFromUserRelays, userState.user?.pubkey])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -274,3 +274,16 @@ export function orderEventsChronologically(
|
|||||||
|
|
||||||
return events
|
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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user