Skip to content

Commit

Permalink
Implement performance flags structure
Browse files Browse the repository at this point in the history
Performance flags (reduxState.controls.performanceFlags) 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).
  • Loading branch information
jameshadfield committed Nov 6, 2024
1 parent f046672 commit 1542bc6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/tree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
performanceFlags: state.controls.performanceFlags,
}))(UnconnectedTree);

export default Tree;
26 changes: 26 additions & 0 deletions src/middleware/performanceFlags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as types from "../actions/types";

/**
* Performance flags (reduxState.controls.performanceFlags) 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 performanceFlags = (_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.performanceFlags = calculate()
}
}
return next(modifiedAction || action); // send action to other middleware / reducers
};

function calculate() {
const flags = new Map();
return flags;
}
3 changes: 2 additions & 1 deletion src/reducers/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ export const getDefaultControlsState = () => {
measurementsDisplay: undefined,
measurementsShowOverallMean: undefined,
measurementsShowThreshold: undefined,
measurementsFilters: {}
measurementsFilters: {},
performanceFlags: new Map(),
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { changeURLMiddleware } from "./middleware/changeURL";
import rootReducer from "./reducers";
// import { loggingMiddleware } from "./middleware/logActions";
import { keepScatterplotStateInSync } from "./middleware/scatterplot";
import { performanceFlags } from "./middleware/performanceFlags";

const middleware = [
keepScatterplotStateInSync,
changeURLMiddleware,
performanceFlags,
// loggingMiddleware
];

Expand Down

0 comments on commit 1542bc6

Please sign in to comment.