Interactive interface for browsing global, full-resolution satellite imagery
re-wrote redux selector to combine with memoization and use object literal syntax
VictorSa6f7e7b5aa74
diff --git a/web/js/components/measure-tool/measure-button.js b/web/js/components/measure-tool/measure-button.jsindex a95b901ff..3401cdd4d 100644--- a/web/js/components/measure-tool/measure-button.js+++ b/web/js/components/measure-tool/measure-button.js@@ -22,6 +22,13 @@ const helpMsg = 'Click: Add a point. Right-click: Cancel. Double-click to compleconst MeasureButton = memo(() => {const dispatch = useDispatch();++ const { isActive, isDistractionFreeModeActive, isMobile } = useSelector((state) => useMemo(() => ({+ isActive: state.measure.isActive,+ isDistractionFreeModeActive: state.ui.isDistractionFreeModeActive,+ isMobile: state.screenSize.isMobileDevice,+ }), [state.measure.isActive, state.ui.isDistractionFreeModeActive, state.screenSize.isMobileDevice]));+const [showAlert, setShowAlert] = useState(true);const [isTouchDevice, setIsTouchDevice] = useState(false);@@ -40,22 +47,12 @@ const MeasureButton = memo(() => {});};- const isActive = useSelector((state) => state.measure.isActive);- const isDistractionFreeModeActive = useSelector((state) => state.ui.isDistractionFreeModeActive);- const isMobile = useSelector((state) => state.screenSize.isMobileDevice);-- const memoizedSelectors = useMemo(() => ({- isActive,- isDistractionFreeModeActive,- isMobile,- }), [isActive, isDistractionFreeModeActive, isMobile]);-const buttonId = 'wv-measure-button';const labelText = 'Measure distances & areas';- const faSize = memoizedSelectors.isMobile ? '2x' : '1x';- const shouldShowAlert = memoizedSelectors.isActive && showAlert;+ const faSize = isMobile ? '2x' : '1x';+ const shouldShowAlert = isActive && showAlert;const message = isTouchDevice ? mobileHelpMsg : helpMsg;- const mobileMeasureButtonStyle = memoizedSelectors.isMobile ? {+ const mobileMeasureButtonStyle = isMobile ? {bottom: '20px',fontSize: '14.3px',height: '44px',@@ -76,14 +73,14 @@ const MeasureButton = memo(() => {/>)}- {!memoizedSelectors.isDistractionFreeModeActive && (+ {!isDistractionFreeModeActive && (<Buttonid={buttonId}className="wv-measure-button wv-toolbar-button"aria-label={labelText}onTouchEnd={onButtonClick}onMouseDown={onButtonClick}- disabled={memoizedSelectors.isActive}+ disabled={isActive}style={mobileMeasureButtonStyle}><UncontrolledTooltip