@@ -73,6 +73,7 @@ import {
7373 queryBrowserToggleAllSeries ,
7474 queryBrowserToggleIsEnabled ,
7575 queryBrowserToggleSeries ,
76+ showGraphs ,
7677 toggleGraphs ,
7778} from '../actions/observe' ;
7879
@@ -94,7 +95,7 @@ import {
9495import { MonitoringState } from '../reducers/observe' ;
9596import { DropDownPollInterval } from './dropdown-poll-interval' ;
9697import { useBoolean } from './hooks/useBoolean' ;
97- import { getLegacyObserveState , usePerspective } from './hooks/usePerspective' ;
98+ import { getLegacyObserveState , getObserveState , usePerspective } from './hooks/usePerspective' ;
9899import KebabDropdown from './kebab-dropdown' ;
99100import { colors , Error , QueryBrowser } from './query-browser' ;
100101import { QueryParams } from './query-params' ;
@@ -321,22 +322,19 @@ export const ToggleGraph: React.FC = () => {
321322 const { perspective } = usePerspective ( ) ;
322323
323324 const hideGraphs = useSelector (
324- ( state : MonitoringState ) => ! ! getLegacyObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
325+ ( state : MonitoringState ) => ! ! getObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
325326 ) ;
326327
327328 const dispatch = useDispatch ( ) ;
328329 const toggle = React . useCallback ( ( ) => dispatch ( toggleGraphs ( ) ) , [ dispatch ] ) ;
330+
329331 // Use an empty useEffect to get access to the cleanup function so that if graphs are
330- // currently hidden then we toggle one more time as we unmount
331- React . useEffect (
332- ( ) => ( ) => {
333- if ( hideGraphs ) {
334- toggle ( ) ;
335- }
336- } ,
337- // eslint-disable-next-line react-hooks/exhaustive-deps
338- [ hideGraphs ] ,
339- ) ;
332+ // currently hidden then we show the graphs as we unmount
333+ React . useEffect ( ( ) => {
334+ return ( ) => {
335+ dispatch ( showGraphs ( ) ) ;
336+ } ;
337+ } , [ dispatch ] ) ;
340338
341339 const icon = hideGraphs ? < ChartLineIcon /> : < CompressIcon /> ;
342340
@@ -985,7 +983,7 @@ const QueryBrowserWrapper: React.FC<{
985983 const dispatch = useDispatch ( ) ;
986984
987985 const hideGraphs = useSelector (
988- ( state : MonitoringState ) => ! ! getLegacyObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
986+ ( state : MonitoringState ) => ! ! getObserveState ( perspective , state ) ?. get ( 'hideGraphs' ) ,
989987 ) ;
990988 const queriesList = useSelector ( ( state : MonitoringState ) =>
991989 getLegacyObserveState ( perspective , state ) ?. getIn ( [ 'queryBrowser' , 'queries' ] ) ,
0 commit comments