@@ -9,6 +9,7 @@ import { useFilterStore, filterStoreReducers } from '@/pages/Stream/providers/Fi
9
9
import _ from 'lodash' ;
10
10
import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider' ;
11
11
import { notifyError } from '@/utils/notification' ;
12
+ import { useState } from 'react' ;
12
13
13
14
const { parseQuery } = filterStoreReducers ;
14
15
@@ -83,6 +84,7 @@ export const useFetchCount = () => {
83
84
const [ , setLogsStore ] = useLogsStore ( ( ) => null ) ;
84
85
const { isQuerySearchActive, custSearchQuery, activeMode } = custQuerySearchState ;
85
86
const [ appliedQuery ] = useFilterStore ( ( store ) => store . appliedQuery ) ;
87
+ const [ countLoading , setCountLoading ] = useState ( true ) ;
86
88
87
89
/* eslint-disable no-useless-escape */
88
90
const defaultQuery = `select count(*) as count from \"${ currentStream } \"` ;
@@ -110,13 +112,10 @@ export const useFetchCount = () => {
110
112
endTime : timeRange . endTime ,
111
113
access : [ ] ,
112
114
} ;
113
- const {
114
- isLoading : isCountLoading ,
115
- isRefetching : isCountRefetching ,
116
- refetch : refetchCount ,
117
- } = useQuery (
115
+ const { refetch : refetchCount } = useQuery (
118
116
[ 'fetchCount' , logsQuery ] ,
119
117
async ( ) => {
118
+ setCountLoading ( true ) ;
120
119
const data = await getQueryResult ( logsQuery , query ) ;
121
120
const count = _ . first ( data . data ) ?. count ;
122
121
typeof count === 'number' && setLogsStore ( ( store ) => setTotalCount ( store , count ) ) ;
@@ -127,12 +126,17 @@ export const useFetchCount = () => {
127
126
refetchOnWindowFocus : false ,
128
127
retry : false ,
129
128
enabled : false ,
129
+ onSuccess : ( ) => {
130
+ setCountLoading ( false ) ;
131
+ } ,
132
+ onError : ( ) => {
133
+ setCountLoading ( false ) ;
134
+ } ,
130
135
} ,
131
136
) ;
132
137
133
138
return {
134
- isCountLoading,
135
- isCountRefetching,
139
+ countLoading,
136
140
refetchCount,
137
141
} ;
138
142
} ;
0 commit comments