@@ -9,6 +9,7 @@ import { useFilterStore, filterStoreReducers } from '@/pages/Stream/providers/Fi
99import _ from 'lodash' ;
1010import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider' ;
1111import { notifyError } from '@/utils/notification' ;
12+ import { useState } from 'react' ;
1213
1314const { parseQuery } = filterStoreReducers ;
1415
@@ -83,6 +84,7 @@ export const useFetchCount = () => {
8384 const [ , setLogsStore ] = useLogsStore ( ( ) => null ) ;
8485 const { isQuerySearchActive, custSearchQuery, activeMode } = custQuerySearchState ;
8586 const [ appliedQuery ] = useFilterStore ( ( store ) => store . appliedQuery ) ;
87+ const [ countLoading , setCountLoading ] = useState ( true ) ;
8688
8789 /* eslint-disable no-useless-escape */
8890 const defaultQuery = `select count(*) as count from \"${ currentStream } \"` ;
@@ -110,13 +112,10 @@ export const useFetchCount = () => {
110112 endTime : timeRange . endTime ,
111113 access : [ ] ,
112114 } ;
113- const {
114- isLoading : isCountLoading ,
115- isRefetching : isCountRefetching ,
116- refetch : refetchCount ,
117- } = useQuery (
115+ const { refetch : refetchCount } = useQuery (
118116 [ 'fetchCount' , logsQuery ] ,
119117 async ( ) => {
118+ setCountLoading ( true ) ;
120119 const data = await getQueryResult ( logsQuery , query ) ;
121120 const count = _ . first ( data . data ) ?. count ;
122121 typeof count === 'number' && setLogsStore ( ( store ) => setTotalCount ( store , count ) ) ;
@@ -127,12 +126,17 @@ export const useFetchCount = () => {
127126 refetchOnWindowFocus : false ,
128127 retry : false ,
129128 enabled : false ,
129+ onSuccess : ( ) => {
130+ setCountLoading ( false ) ;
131+ } ,
132+ onError : ( ) => {
133+ setCountLoading ( false ) ;
134+ } ,
130135 } ,
131136 ) ;
132137
133138 return {
134- isCountLoading,
135- isCountRefetching,
139+ countLoading,
136140 refetchCount,
137141 } ;
138142} ;
0 commit comments