Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Merge branch 'redux-toolbar-1576' of https://github.com/nasa-gibs/worldview into redux-sidebar-1623

Benjamin Kinga1f75fd2b502
diff --cc web/js/containers/share.js
index ce51e8036,fb0f0948c..d542f46e7
--- a/web/js/containers/share.js
+++ b/web/js/containers/share.js
@@@ -32,9 -34,23 +34,27 @@@ class ShareLinkContainer extends Compon
this.state = {
shortLinkKey: '',
isShort: false,
- tooltipOpen: false
+ tooltipOpen: false,
+ queryString: history.location.search || ''
};
}
+ componentDidMount() {
+ this.unlisten = history.listen((location, action) => {
+ const newString = location.search;
+ const { queryString } = this.state;
+ if (queryString !== newString) {
- this.setState({ queryString: newString });
++ this.setState({
++ queryString: newString,
++ isShort: false,
++ shortLinkKey: ''
++ });
+ }
+ });
+ }
+
+ componentWillUnmount() {
+ if (this.unlisten) this.unlisten();
+ }
getShortLink() {
const { requestShortLink, mock } = this.props;
const link = this.getPermalink();
@@@ -42,9 -58,8 +62,7 @@@
return requestShortLink(location);
}
onToggleShorten() {
- const { queryString } = this.props;
- const { shortLinkKey, isShort } = this.state;
-
+ const { shortLinkKey, isShort, queryString } = this.state;
-
if (!isShort && shortLinkKey !== queryString) {
this.getShortLink();
this.setState({
@@@ -89,12 -104,12 +107,7 @@@
}
}
static getDerivedStateFromProps(nextProps, prevState) {
-- if (prevState.shortLinkKey !== nextProps.queryString) {
-- return {
-- isShort: false,
-- shortLinkKey: ''
-- };
-- } else if (nextProps.shortLink.error && prevState.isShort) {
++ if (nextProps.shortLink.error && prevState.isShort) {
return { isShort: false, showErrorTooltip: true };
} else return null;
}
@@@ -127,7 -142,7 +140,6 @@@
render() {
const { shortLink } = this.props;
const { isShort } = this.state;
--
const value =
shortLink.isLoading && isShort
? 'Please wait...'
diff --cc web/js/modules/combine-reducers.js
index 624d798e7,4cb3a5d5f..83213d17f
--- a/web/js/modules/combine-reducers.js
+++ b/web/js/modules/combine-reducers.js
@@@ -11,12 -10,16 +10,13 @@@ import
notificationsReducer
} from './notifications/reducers';
import { getProjInitialState } from './projection/util';
+import { compareReducer } from './compare/reducers';
++import sidebarReducer from './sidebar/reducers';
+import {
+ layerReducer,
+ getInitialState as getLayersInitialState
+} from './layers/reducers';
-export function getInitialState(models, config, parameters) {
- return {
- parameters,
- config,
- models,
- legacy: models,
- proj: getProjInitialState(config)
- };
-}
const responsiveStateReducer = createResponsiveStateReducer(
{
extraSmall: 500,