diff --git a/src/components/tree/index.ts b/src/components/tree/index.ts index 07218e725..2e08f3303 100644 --- a/src/components/tree/index.ts +++ b/src/components/tree/index.ts @@ -30,7 +30,8 @@ const Tree = connect((state: RootState) => ({ tipLabelKey: state.controls.tipLabelKey, narrativeMode: state.narrative.display, animationPlayPauseButton: state.controls.animationPlayPauseButton, - showOnlyPanels: state.controls.showOnlyPanels + showOnlyPanels: state.controls.showOnlyPanels, + performanceToggles: state.controls.performanceToggles, }))(UnconnectedTree); export default Tree; diff --git a/src/middleware/performanceToggles.js b/src/middleware/performanceToggles.js new file mode 100644 index 000000000..c8f8103ce --- /dev/null +++ b/src/middleware/performanceToggles.js @@ -0,0 +1,26 @@ +import * as types from "../actions/types"; + +/** + * Performance toggles (reduxState.controls.performanceToggles) represent flags + * for which we enable/disable certain functionality in Auspice. These flags + * shouldn't be depended on, i.e. Auspice should work just fine without them + * (but may be a little slow). + */ + + +export const performanceToggles = (_store) => (next) => (action) => { + let modifiedAction; + switch (action.type) { + case types.URL_QUERY_CHANGE_WITH_COMPUTED_STATE: /* fallthrough */ + case types.CLEAN_START: { + modifiedAction = {...action}; + modifiedAction.controls.performanceToggles = calculate(action.controls) + } + } + return next(modifiedAction || action); // send action to other middleware / reducers +}; + +function calculate(controlsState) { + const toggles = new Map(); + return toggles; +} \ No newline at end of file diff --git a/src/reducers/controls.ts b/src/reducers/controls.ts index 5fc96bb77..d9f080d53 100644 --- a/src/reducers/controls.ts +++ b/src/reducers/controls.ts @@ -139,7 +139,8 @@ export const getDefaultControlsState = () => { measurementsDisplay: undefined, measurementsShowOverallMean: undefined, measurementsShowThreshold: undefined, - measurementsFilters: {} + measurementsFilters: {}, + performanceToggles: new Map(), }; }; diff --git a/src/store.ts b/src/store.ts index 4943b23ae..efa6d214f 100644 --- a/src/store.ts +++ b/src/store.ts @@ -3,10 +3,12 @@ import { changeURLMiddleware } from "./middleware/changeURL"; import rootReducer from "./reducers"; // import { loggingMiddleware } from "./middleware/logActions"; import { keepScatterplotStateInSync } from "./middleware/scatterplot"; +import { performanceToggles } from "./middleware/performanceToggles"; const middleware = [ keepScatterplotStateInSync, changeURLMiddleware, + performanceToggles, // loggingMiddleware ];