Skip to content

Commit

Permalink
clear up light clients and replace with wss
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod committed Aug 19, 2024
1 parent dff4997 commit b03b1a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
28 changes: 7 additions & 21 deletions src/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,22 @@ import { Route, Routes } from 'react-router-dom'

import { About } from '@/pages/About'

import { useEffect, useState } from 'react'
import { collectiveClient } from './clients'
import { toast } from 'sonner'

const pages = (lcStatus: boolean) => [
const pages = [
{
path: '',
element: <About lcStatus={lcStatus} />,
element: <About />,
},
{
path: '/about',
element: <About />,
},
]

export const Content = () => {
const [lightClientLoaded, setLightClientLoaded] = useState<boolean>(false)

useEffect(() => {
collectiveClient.finalizedBlock$.subscribe((finalizedBlock) => {
if (finalizedBlock.number && !lightClientLoaded) {
setLightClientLoaded(true)
}
})
}, [lightClientLoaded])

useEffect(() => {
lightClientLoaded && toast.success('Light client: Synced')
}, [lightClientLoaded])

return (
<>
<Routes>
{pages(lightClientLoaded).map(({ path, element }, i) => {
{pages.map(({ path, element }, i) => {
return <Route key={`page_${i}`} path={path} element={element} />
})}
</Routes>
Expand Down
7 changes: 1 addition & 6 deletions src/pages/About/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { Button } from '@/components/ui/button'

type Props = {
lcStatus: boolean
}

const openInNewTab = (url: string | URL | undefined) => {
window.open(url, '_blank', 'noopener,noreferrer')
}

export const About = ({ lcStatus }: Props) => {
console.log('Light client status:', lcStatus)
export const About = () => {
return (
<main className="grid flex-1 items-start gap-4 p-4 sm:mx-[5%] xl:mx-[20%] mx-0 sm:px-6 sm:py-0 md:gap-8">
<h1 className="font-unbounded text-primary flex-1 shrink-0 whitespace-nowrap text-xl font-semibold tracking-tight sm:grow-0">
Expand Down

0 comments on commit b03b1a0

Please sign in to comment.