@@ -10,8 +10,8 @@ import type { PlotParams, TimeRange, VariableKey, VariableParams } from '@/url2'
1010import { useLiveModeStore } from '@/store2/liveModeStore' ;
1111import { useMemo } from 'react' ;
1212import { useQuery , type UseQueryResult } from '@tanstack/react-query' ;
13- import { useStatsHouse } from '@/store2' ;
1413import { getLoadPlotUrlParamsLight } from '@/store2/plotDataStore/loadPlotData2' ;
14+ import { usePlotHeal } from '@/hooks/usePlotHeal' ;
1515
1616export const ApiBadgesEndpoint = '/api/badges' ;
1717
@@ -52,10 +52,7 @@ export function useApiBadges<T = ApiBadges>(
5252 return getLoadPlotUrlParamsLight ( plot , timeRange , timeShifts , variables , interval ) ;
5353 } , [ interval , plot , timeRange , timeShifts , variables ] ) ;
5454
55- const plotHeals = useStatsHouse ( ( s ) => {
56- const status = s . plotHeals [ plot . id ] ;
57- return ! ( ! ! status && ! status . status && status . lastTimestamp + status . timeout * 1000 > Date . now ( ) ) ;
58- } ) ;
55+ const plotHeals = usePlotHeal ( plot . id ) ;
5956
6057 const fetchParams = useMemo ( ( ) => {
6158 if ( ! plot ?. id ) {
@@ -65,7 +62,12 @@ export function useApiBadges<T = ApiBadges>(
6562 } , [ interval , plot , priority , timeRange , timeShifts , variables ] ) ;
6663
6764 return useQuery ( {
68- enabled : plotHeals && enabled ,
65+ enabled : ( ) : boolean => {
66+ if ( enabled ) {
67+ return plotHeals === true || plotHeals > Date . now ( ) ;
68+ }
69+ return false ;
70+ } ,
6971 select,
7072 queryKey : [ ApiBadgesEndpoint , keyParams ] ,
7173 queryFn : async ( { signal } ) => {
0 commit comments