From 599c30da17876ca25600957f75bcec015a2de3ac Mon Sep 17 00:00:00 2001 From: Patrick Bennett Date: Fri, 5 Apr 2024 16:09:40 -0400 Subject: [PATCH] Change staleTime to refetchInterval so validator info is refetched once 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 --- ui/src/api/queries.ts | 2 +- ui/src/components/ValidatorDetails.tsx | 2 +- ui/src/components/_Overview.tsx | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/src/api/queries.ts b/ui/src/api/queries.ts index f4cd7e4a..679dd2a6 100644 --- a/ui/src/api/queries.ts +++ b/ui/src/api/queries.ts @@ -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, }) diff --git a/ui/src/components/ValidatorDetails.tsx b/ui/src/components/ValidatorDetails.tsx index fe840847..728e3807 100644 --- a/ui/src/components/ValidatorDetails.tsx +++ b/ui/src/components/ValidatorDetails.tsx @@ -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 } diff --git a/ui/src/components/_Overview.tsx b/ui/src/components/_Overview.tsx index f2f7f6bc..8f57b0ec 100644 --- a/ui/src/components/_Overview.tsx +++ b/ui/src/components/_Overview.tsx @@ -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,