Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add active layer filtering to get current projection layers

Ed Plato0a7480cd3ddc
diff --git a/web/js/components/timeline/timeline-data/timeline-data.js b/web/js/components/timeline/timeline-data/timeline-data.js
index 30af1d44f..43c20e45d 100644
--- a/web/js/components/timeline/timeline-data/timeline-data.js
+++ b/web/js/components/timeline/timeline-data/timeline-data.js
@@ -41,7 +41,12 @@ class TimelineData extends Component {
}
componentDidUpdate(prevProps, prevState) {
- const { activeLayers, isProductPickerOpen, isDataCoveragePanelOpen } = this.props;
+ const {
+ activeLayers,
+ isProductPickerOpen,
+ isDataCoveragePanelOpen,
+ projection,
+ } = this.props;
const { shouldIncludeHiddenLayers } = this.state;
if (!prevProps.isProductPickerOpen && isProductPickerOpen && isDataCoveragePanelOpen) {
@@ -49,9 +54,10 @@ class TimelineData extends Component {
return;
}
+ const projectionChange = prevProps.projection !== projection;
const toggleHiddenChange = prevState.shouldIncludeHiddenLayers !== shouldIncludeHiddenLayers;
// need to update layer toggles for show/hide/remove
- if (!lodashIsEqual(prevProps.activeLayers, activeLayers) || toggleHiddenChange) {
+ if (projectionChange || !lodashIsEqual(prevProps.activeLayers, activeLayers) || toggleHiddenChange) {
// update coverage including layer added/removed and option changes (active/inactive)
const layers = this.getActiveLayers(activeLayers);
this.setActiveLayers(layers);
@@ -366,20 +372,26 @@ function mapStateToProps(state) {
date,
layers,
modal,
+ proj,
} = state;
const {
appNow,
} = date;
- const activeLayers = layers[compare.activeString].filter((activeLayer) => activeLayer.startDate);
+ // handle active layer filtering
+ const activeLayers = layers[compare.activeString];
+ const projection = proj.id;
+ const activeLayersFiltered = activeLayers.filter((layer) => layer.startDate && layer.projections[projection]);
+
const { hoveredLayer } = layers;
const isProductPickerOpen = modal.isOpen && modal.id === 'LAYER_PICKER_COMPONENT';
return {
- activeLayers,
+ activeLayers: activeLayersFiltered,
hoveredLayer,
appNow,
isProductPickerOpen,
+ projection,
};
}
@@ -397,6 +409,7 @@ TimelineData.propTypes = {
isProductPickerOpen: PropTypes.bool,
parentOffset: PropTypes.number,
position: PropTypes.number,
+ projection: PropTypes.string,
setMatchingTimelineCoverage: PropTypes.func,
timelineStartDateLimit: PropTypes.string,
timeScale: PropTypes.string,
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index af0c16260..ef6e652ed 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -1377,6 +1377,7 @@ function mapStateToProps(state) {
browser,
date,
animation,
+ proj,
sidebar,
modal,
tour,
@@ -1401,8 +1402,12 @@ function mapStateToProps(state) {
const isSmallScreen = lessThan.medium;
const isScreenWidthLessThan350 = screenWidth < 350;
const isScreenWidthLessThan450 = screenWidth < 450;
- let hasSubdailyLayers = hasSubDaily(layers[compare.activeString]);
- const activeLayers = layers[compare.activeString].filter((activeLayer) => activeLayer.startDate);
+
+ // handle active layer filtering and check for subdaily
+ const activeLayers = layers[compare.activeString];
+ const projection = proj.id;
+ const activeLayersFiltered = activeLayers.filter((layer) => layer.startDate && layer.projections[projection]);
+ let hasSubdailyLayers = hasSubDaily(activeLayers);
let updatedInterval = interval;
let updatedCustomInterval = customInterval;
@@ -1425,7 +1430,7 @@ function mapStateToProps(state) {
hasSubdailyLayers = hasSubDaily(layers.active) || hasSubDaily(layers.activeB);
endTime = getEndTime(layers, config);
} else {
- hasSubdailyLayers = hasSubDaily(layers[compare.activeString]);
+ hasSubdailyLayers = hasSubDaily(activeLayers);
endTime = layersLastDateTime(layers[activeString], config);
}
endTime = appNow;
@@ -1456,7 +1461,7 @@ function mapStateToProps(state) {
);
return {
appNow,
- activeLayers,
+ activeLayers: activeLayersFiltered,
isTourActive: tour.active,
isSmallScreen,
isScreenWidthLessThan350,