Skip to content

Commit

Permalink
Change staleTime to refetchInterval so validator info is refetched on…
Browse files Browse the repository at this point in the history
…ce a minute so it's always tracking stakers/stake changes.

Create new wrapper interface for passing the validator in Overview component instead of exporting from ValidatorDetails
  • Loading branch information
pbennett committed Apr 5, 2024
1 parent 76d37d1 commit 599c30d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/src/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const validatorQueryOptions = (validatorId: number | string) =>
queryOptions({
queryKey: ['validator', String(validatorId)],
queryFn: () => fetchValidator(validatorId),
staleTime: 1000 * 60, // every minute
refetchInterval: 1000, // 1 min polling on validator info
retry: false,
})

Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/ValidatorDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { validatorHasAvailableSlots } from '@/utils/contracts'
import { formatDuration } from '@/utils/dayjs'
import { ellipseAddress } from '@/utils/ellipseAddress'

export interface ValidatorDetailsProps {
interface ValidatorDetailsProps {
validator: Validator
}

Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/_Overview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'
import { ValidatorDetailsProps } from '@/components/ValidatorDetails'
import { Validator } from '@/interfaces/validator'

export function Overview({ validator }: ValidatorDetailsProps) {
interface OverviewProps {
validator: Validator
}

export function Overview({ validator }: OverviewProps) {
const poolData = validator?.pools.map((pool, index) => ({
name: `Pool ${index + 1}`,
stakers: pool.totalStakers,
Expand Down

0 comments on commit 599c30d

Please sign in to comment.