Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Prevent loading of data product if product is not in active layers #1793

Benjamin King771fb98741d8
diff --git a/web/js/modules/data/util.js b/web/js/modules/data/util.js
index d4f050d2f..27fb5dfca 100644
--- a/web/js/modules/data/util.js
+++ b/web/js/modules/data/util.js
@@ -1,4 +1,5 @@
import update from 'immutability-helper';
+import { find as lodashFind, get as lodashGet } from 'lodash';
/**
* Update sidebar state when location-pop action occurs
*
@@ -16,7 +17,16 @@ export function mapLocationToDataState(
if (parameters.download) {
const productId = parameters.download;
if (productId) {
- if (!config.products[productId]) {
+ const activeString =
+ lodashGet(stateFromLocation, 'compare.activeString') ||
+ lodashGet(state, 'compare.activeString');
+ const activeLayers =
+ lodashGet(stateFromLocation, `layers.${activeString}`) ||
+ lodashGet(state, `layers.${activeString}`);
+ if (
+ !config.products[productId] ||
+ !lodashFind(activeLayers, { product: productId })
+ ) {
console.warn('No such product: ' + productId);
stateFromLocation = update(stateFromLocation, {
data: { selectedProduct: { $set: '' } }