Skip to content

Commit

Permalink
Remove redundant call to listAllNodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang committed Jan 23, 2025
1 parent 630c3e9 commit 1d27e5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
7 changes: 1 addition & 6 deletions components/registry/Registry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ const searchClient = algoliasearch(
process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_KEY as string
)

type RegistryProps = {
totalPages: number
currentPage: number
setPage: (page: number) => void
nodes: Node[]
}
type RegistryProps = {}

const Registry: React.FC<RegistryProps> = ({}) => {
return (
Expand Down
31 changes: 1 addition & 30 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,10 @@
import * as React from 'react'
import Registry from '../components/registry/Registry'
import { useListAllNodes } from '../src/api/generated'
import { Spinner } from 'flowbite-react'
import { toast } from 'react-toastify'

function NodeList() {
const [page, setPage] = React.useState<number>(1)
const getAllNodesQuery = useListAllNodes({
page: page,
limit: 16,
})
const nodes = getAllNodesQuery.data?.nodes || []

React.useEffect(() => {
if (getAllNodesQuery.isError) {
toast.error('Error getting custom nodes')
}
}, [getAllNodesQuery])

if (getAllNodesQuery.isLoading) {
return (
<div className="flex items-center justify-center h-screen">
<Spinner className="" />
</div>
)
}

return (
<>
<Registry
nodes={nodes}
totalPages={getAllNodesQuery.data?.totalPages || 1}
currentPage={getAllNodesQuery.data?.page || 1}
setPage={setPage}
/>
<Registry />
</>
)
}
Expand Down

0 comments on commit 1d27e5b

Please sign in to comment.