Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group related dataset-related state into object #502

Open
ShrimpCryptid opened this issue Dec 20, 2024 · 0 comments
Open

Group related dataset-related state into object #502

ShrimpCryptid opened this issue Dec 20, 2024 · 0 comments
Labels
internals Tech debt, refactoring, dependencies, etc.

Comments

@ShrimpCryptid
Copy link
Contributor

Use Case

Somewhat parallel request to #492, refactoring state management. This is a lower-hanging-fruit version of it!

Currently there are a lot of loose state variables that are being passed around the viewer, which makes props for certain components (like CanvasWrapper) very large and unwieldy:

<CanvasWrapper
  loading={isDatasetLoading}
  loadingProgress={datasetLoadProgress}
  canv={canv}
  collection={collection || null}
  vectorData={motionDeltas}
  dataset={dataset}
  datasetKey={datasetKey}
  featureKey={featureKey}
  selectedBackdropKey={selectedBackdropKey}
  colorRamp={getColorMap(colorRampData, colorRampKey, colorRampReversed)}
  colorRampMin={colorRampMin}
  colorRampMax={colorRampMax}
  isRecording={isRecording}
  categoricalColors={categoricalPalette}
  selectedTrack={selectedTrack}
  config={config}
  updateConfig={updateConfig}
  onTrackClicked={onTrackClicked}
  inRangeLUT={inRangeLUT}
  onMouseHover={(id: number): void => {
    const isObject = id !== BACKGROUND_ID;
    setShowObjectHoverInfo(isObject);
    if (isObject) {
      setLastValidHoveredId(id);
    }
  }}
  onMouseLeave={() => setShowObjectHoverInfo(false)}
  showAlert={isInitialDatasetLoaded ? showAlert : undefined}
/>

Some state could be grouped into objects, the way config, scatterPlotConfig, and vectorConfig are grouped.

Acceptance Criteria

Group related state together and pass into objects, updating their prop APIs:

  • datasetState => collection + dataset + datasetKey
  • visualizationState => featureKey + selectedBackdropKey + colorRamp + colorRampMin + colorRampMax + categoricalColors + selectedTrack + inRangeLUT

Types should be defined for each of these state objects in a types.ts file outside of Viewer.tsx.

Details

Please provide any helpful specifications

@ShrimpCryptid ShrimpCryptid added the internals Tech debt, refactoring, dependencies, etc. label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals Tech debt, refactoring, dependencies, etc.
Projects
None yet
Development

No branches or pull requests

1 participant