From 9f6b56a93346ec826ae06aa98ee1ce5e8702fb26 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:09:16 -0700 Subject: [PATCH] Set default colorings in getDefaultControlsState Centralize the defaults for consistency. Also, this avoids the need to mark the property as optional on the state. --- src/actions/recomputeReduxState.js | 2 -- src/reducers/controls.ts | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index 7ab386ea9..0345f4293 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -400,8 +400,6 @@ const modifyControlsStateViaTree = (state, tree, treeToo, colorings) => { * only when a file is dropped. (I've gone down too many rabbit holes in this PR to * do this now, unfortunately.) james, 2023 */ - state.coloringsPresentOnTree = new Set(); - state.coloringsPresentOnTreeWithConfidence = new Set(); // subset of above let coloringsToCheck = []; if (colorings) { diff --git a/src/reducers/controls.ts b/src/reducers/controls.ts index 39c3de277..c04271d0c 100644 --- a/src/reducers/controls.ts +++ b/src/reducers/controls.ts @@ -108,8 +108,11 @@ export interface BasicControlsState { canTogglePanelLayout: boolean colorBy: string colorByConfidence: boolean - coloringsPresentOnTree?: Set - coloringsPresentOnTreeWithConfidence?: Set + coloringsPresentOnTree: Set + + /** subset of coloringsPresentOnTree */ + coloringsPresentOnTreeWithConfidence: Set + colorScale?: ColorScale dateMax: string dateMaxNumeric: number @@ -207,6 +210,8 @@ export const getDefaultControlsState = (): ControlsState => { colorBy: defaults.colorBy, colorByConfidence: false, colorScale: undefined, + coloringsPresentOnTree: new Set(), + coloringsPresentOnTreeWithConfidence: new Set(), explodeAttr: undefined, selectedBranchLabel: "none", showAllBranchLabels: false,