File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import {
2828} from 'src/types'
2929
3030// Selectors
31- import { getAllVariables } from 'src/variables/selectors'
31+ import { getAllVariablesMemoized } from 'src/variables/selectors'
3232import { getWindowPeriodFromQueryBuilder } from 'src/timeMachine/selectors'
3333
3434// Constants
@@ -235,7 +235,8 @@ const mstp = (state: AppState, ownProps: OwnProps) => {
235235 state ,
236236 view ?. id
237237 )
238- const variables = getAllVariables ( state )
238+ const variables = getAllVariablesMemoized ( state )
239+
239240 return { variables, view, windowPeriodFromQueryBuilder}
240241}
241242
Original file line number Diff line number Diff line change 11// Libraries
22import { get } from 'lodash'
3+ import { createSelector } from 'reselect'
34
45// Utils
56import { getActiveQuery } from 'src/timeMachine/selectors'
@@ -15,6 +16,7 @@ import {
1516 WINDOW_PERIOD ,
1617} from 'src/variables/constants'
1718import { currentContext } from 'src/shared/selectors/currentContext'
19+ import { getCurrentDashboardId } from 'src/dashboards/selectors/'
1820
1921// Types
2022import {
@@ -137,6 +139,34 @@ export const getAllVariables = (
137139 return vars
138140}
139141
142+ const getAllVariableIds = createSelector (
143+ state => state ,
144+ getCurrentDashboardId ,
145+ ( state , currentDashboardId ) => {
146+ return getUserVariableNames ( state , currentDashboardId ) . concat ( [
147+ TIME_RANGE_START ,
148+ TIME_RANGE_STOP ,
149+ WINDOW_PERIOD ,
150+ ] )
151+ }
152+ )
153+
154+ export const getAllVariablesMemoized = createSelector (
155+ state => state ,
156+ getAllVariableIds ,
157+ ( state , allVariableIds ) => {
158+ const variables = [ ]
159+ for ( const variableId of allVariableIds ) {
160+ const variable = getVariable ( state , variableId )
161+ if ( variable ) {
162+ variables . push ( variable )
163+ }
164+ }
165+
166+ return variables
167+ }
168+ )
169+
140170export const getAllVariablesForZoomRequery = (
141171 state : AppState ,
142172 domain : number [ ] ,
You can’t perform that action at this time.
0 commit comments