Interactive interface for browsing global, full-resolution satellite imagery
fix request bouncing issue
Jason Kent3335b11095d4
diff --git a/web/js/components/smart-handoffs/granule-count.js b/web/js/components/smart-handoffs/granule-count.jsindex 7943254c8..301ec4665 100644--- a/web/js/components/smart-handoffs/granule-count.js+++ b/web/js/components/smart-handoffs/granule-count.js@@ -38,6 +38,9 @@ export default function GranuleCount (props) {(prev, curr) => prev + parseInt(curr.granule_size, 10), 0,);+ /**+ * Fetch granule data for the specified selected layer/collection+ */const updateGranules = async () => {const { southWest, northEast } = currentExtent || {};let newTotalGranules = 0;@@ -68,7 +71,6 @@ export default function GranuleCount (props) {if (newGranuleDownloadSize === 0) {newGranuleDownloadSize = getDownloadSize(totalEntries);}-setState({isLoading: false,totalGranules: newTotalGranules,@@ -77,9 +79,7 @@ export default function GranuleCount (props) {});};- /**- * Fetch granule data for the specified selected layer/collection- */+ /** Trigger granule request when extent, collection, or date changes */useEffect(() => {setState({isLoading: true,diff --git a/web/js/components/util/image-crop.js b/web/js/components/util/image-crop.jsindex 3442dabae..2c43cb58a 100644--- a/web/js/components/util/image-crop.js+++ b/web/js/components/util/image-crop.js@@ -54,6 +54,7 @@ export default class Crop extends React.Component {const {onClose,onChange,+ onDragStop,maxWidth,maxHeight,showCoordinates,@@ -78,6 +79,7 @@ export default class Crop extends React.Component {}}keepSelection={keepSelection}onComplete={(crop) => {+ onDragStop(crop);if (!crop.width || !crop.height) {onClose();}@@ -97,6 +99,7 @@ Crop.defaultProps = {height: 10,maxHeight: window.innerWidth,maxWidth: window.innerHeight,+ onDragStop: () => {},keepSelection: false,width: 30,x: 20,@@ -106,6 +109,7 @@ Crop.defaultProps = {Crop.propTypes = {onChange: PropTypes.func.isRequired,onClose: PropTypes.func.isRequired,+ onDragStop: PropTypes.func,bottomLeftStyle: PropTypes.object,coordinates: PropTypes.object,height: PropTypes.number,diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.jsindex e6646f143..e2f406f7b 100644--- a/web/js/containers/sidebar/smart-handoff.js+++ b/web/js/containers/sidebar/smart-handoff.js@@ -3,7 +3,6 @@ import React, { Component } from 'react';import PropTypes from 'prop-types';import { connect } from 'react-redux';import * as olProj from 'ol/proj';-import { debounce as lodashDebounce } from 'lodash';import googleTagManager from 'googleTagManager';import moment from 'moment';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';@@ -30,16 +29,11 @@ const STD_NRT_MAP = {};/**- * The Smart-Handoff components replaces the existing data download capability- * by directing users to select specific layer products within Worldview and 'hand' them 'off'- * to NASA's Earthdata Search web tool that will proceed in fetching corresponding+ * The Smart-Handoff component directs users to select specific layer products+ * in NASA's Earthdata Search web tool that will proceed in fetching corresponding* layer data and granule files that are available for download.*/class SmartHandoff extends Component {- /**- * SmartHandoff's default constructor- * @param {*} props | A read-only object used to transfer data from a parent component- */constructor(props) {super(props);@@ -48,7 +42,6 @@ class SmartHandoff extends Component {screenHeight,} = props;- // Set default statethis.state = {boundaries: {x: screenWidth / 2 - 100,@@ -66,7 +59,6 @@ class SmartHandoff extends Component {this.onCheckboxToggle = this.onCheckboxToggle.bind(this);this.onClickDownload = this.onClickDownload.bind(this);this.updateExtent = this.updateExtent.bind(this);- this.debouncedUpdateExtent = lodashDebounce(this.updateExtent, 500, { leading: true });}componentDidUpdate(prevProps) {@@ -92,18 +84,20 @@ class SmartHandoff extends Component {* Fires when the bounding box / crop toggle is activated and changed*/updateExtent(coordinates, boundaries, extent) {- this.setState({- boundaries,- coordinates,- currentExtent: extent,- });+ const newState = { boundaries, coordinates };+ if (extent) {+ newState.currentExtent = extent;+ }+ this.setState(newState);}/*** Fires when the image cropper is moved around on the map; updates the SW and NE lat/lon coordinates.* @param {*} boundaries - the focal point to which layer data should be contained within+ * @param {boolean} setExtent - should the subsequent setState call set the extent, which will trigger+ * the granule count async requests*/- onBoundaryChange(boundaries) {+ onBoundaryChange(boundaries, setExtent) {const { proj, map, selectedCollection } = this.props;if (!selectedCollection) return;@@ -155,7 +149,7 @@ class SmartHandoff extends Component {};if (selectedCollection && extent) {- this.debouncedUpdateExtent(coordinates, newBoundaries, extent);+ this.updateExtent(coordinates, newBoundaries, setExtent && extent);}}@@ -329,6 +323,9 @@ class SmartHandoff extends Component {maxHeight={screenHeight}maxWidth={screenWidth}onChange={this.onBoundaryChange}+ onDragStop={(crop) => {+ this.onBoundaryChange(crop, true);+ }}onClose={onClose}keepSelectionbottomLeftStyle={{