Skip to content

Commit 77c50e9

Browse files
authored
fix: fixes the issue that toggling the timerange didnt update the queries timerange (#3582)
1 parent a67e90e commit 77c50e9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/flows/context/flow.query.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {FC, useContext, useEffect, useState, useRef} from 'react'
1+
import React, {FC, useContext, useEffect, useRef} from 'react'
22
import {useDispatch, useSelector} from 'react-redux'
33
import {FlowContext} from 'src/flows/context/flow.current'
44
import {ResultsContext} from 'src/flows/context/results'
@@ -62,21 +62,23 @@ export const FlowQueryProvider: FC = ({children}) => {
6262
const {setResult, setStatuses, statuses} = useContext(ResultsContext)
6363
const {query: queryAPI, basic: basicAPI} = useContext(QueryContext)
6464
const org = useSelector(getOrg) ?? {id: ''}
65-
const [prevLower, setPrevLower] = useState<string>(flow?.range?.lower)
6665

6766
const dispatch = useDispatch()
6867
const notebookQueryKey = `queryAll-${flow?.name}`
6968

7069
useEffect(() => {
71-
if (flow?.range?.lower !== prevLower) {
72-
// only run the query if a previously set value has been changed.
73-
// unless we're in presentation mode, then we should run the query on load.
74-
if (prevLower || flow.readOnly) {
75-
queryAll()
76-
}
77-
setPrevLower(flow?.range?.lower)
70+
if (!flow?.range) {
71+
return
7872
}
79-
}, [flow])
73+
_generateMap()
74+
queryAll()
75+
}, [flow?.range])
76+
77+
useEffect(() => {
78+
if (flow?.readOnly) {
79+
queryAll()
80+
}
81+
}, [flow?.readOnly])
8082

8183
// Share querying event across tabs
8284
const handleStorageEvent = e => {

0 commit comments

Comments
 (0)