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

Fix: Analysis only shows one asset/layer for a collection #582

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions app/scripts/components/analysis/define/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
useRef
} from 'react';
import styled from 'styled-components';
import { uniqBy } from 'lodash';
import { media, multiply, themeVal } from '@devseed-ui/theme-provider';
import { Toolbar, ToolbarIconButton, ToolbarLabel } from '@devseed-ui/toolbar';
import { Dropdown, DropMenu, DropTitle } from '@devseed-ui/dropdown';
Expand Down Expand Up @@ -99,12 +98,10 @@
}
`;

export const allAvailableDatasetsLayers: DatasetLayer[] = uniqBy(
Object.values(datasets)
export const allAvailableDatasetsLayers: DatasetLayer[] = Object.values(datasets)
.map((dataset) => (dataset as VedaDatum<DatasetData>).data.layers)

Check warning on line 102 in app/scripts/components/analysis/define/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Use a ! assertion to more succinctly remove null and undefined from the type
.flat(),
'stacCol'
).filter(d => d.type !== 'vector');
.flat()
.filter(d => d.type !== 'vector');

export default function Analysis() {

Expand Down Expand Up @@ -158,7 +155,7 @@
const onDatasetLayerChange = useCallback(
(e) => {
const id = e.target.id;
let newDatasetsLayers = [...(datasetsLayers || [])];

Check warning on line 158 in app/scripts/components/analysis/define/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator
if (e.target.checked) {
const newDatasetLayer = allAvailableDatasetsLayers.find(
(l) => l.id === id
Expand All @@ -184,14 +181,14 @@
const selectableDatasetLayersIds = selectableDatasetLayers.map(
(layer) => layer.id
);
const cleanedDatasetsLayers = datasetsLayers?.filter((l) =>

Check warning on line 184 in app/scripts/components/analysis/define/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unnecessary optional chain on a non-nullish value
selectableDatasetLayersIds.includes(l.id)
);

setAnalysisParam('datasetsLayers', cleanedDatasetsLayers);
// Only update when stac search gets updated to avoid triggering an infinite
// read/set state loop
}, [selectableDatasetLayers, setAnalysisParam]);

Check warning on line 191 in app/scripts/components/analysis/define/index.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'datasetsLayers'. Either include it or remove the dependency array

const showTip = !readyToLoadDatasets || !datasetsLayers?.length;

Expand Down
Loading