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

WV-3242 index out of bounds error #5332

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion web/js/mapUI/components/layers/addLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ function AddLayer(props) {
compareMapUi.create(ui.selected, mode);
} else {
const newLayer = await createLayer(def);
ui.selected.getLayers().insertAt(index, newLayer);
const layers = ui.selected.getLayers();
if (index <= layers.getLength()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a bit of a hacky fix to me. Why is this behavior different than when adding any other layers? Surely there is a solution to this further upstream that solves the actual problem, rather than accounting for the problem later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure fixing the source of the bug is feasible within the scope of this story. The source of the issue is a race condition caused by this useEffect hook which is unfortunately critical to how AERONET layers are rendered. Modifying said hook to only reload layers when the newly rendered palette is from AERONET works for the most part but unfortunately causes AERONET layers to not render correctly when hydrated from the url.

layers.insertAt(index, newLayer);
} else {
layers.push(newLayer);
}
}
updateLayerVisibilities();
preloadNextTiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ function UpdateProjection(props) {

useEffect(() => {
if (!ui.selected) return;
if (Object.keys(prevRenderedPalettes).length === Object.keys(renderedPalettes).length) return;
const prevRenderedPalettesKeys = Object.keys(prevRenderedPalettes);
const renderedPalettesKeys = Object.keys(renderedPalettes);
if (prevRenderedPalettesKeys.length === renderedPalettesKeys.length) return;
reloadLayers(null, false);
}, [renderedPalettes]);

Expand Down
Loading