Interactive interface for browsing global, full-resolution satellite imagery
Relocate interval zoomLevel logic #1925
Benjamin Kingb37e75763cea
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex fe7797952..e54ec5101 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -657,13 +657,9 @@ class Timeline extends React.Component {isAnimationPlaying,isAnimationWidgetOpen,isGifActive,- isTourActive,customSelected,customIntervalValue,- customIntervalZoomLevel,- timeScale,- timeScaleChangeUnit,- deltaChangeAmt+ customIntervalZoomLevel} = this.props;// handle update animation positioning and local state from play button/gif creation@@ -701,17 +697,6 @@ class Timeline extends React.Component {if (dateB !== prevProps.dateB && dateB !== this.state.draggerTimeStateB) {this.updateDraggerTimeState(dateB, true);}-- // on tour page change, will update interval to selectedzoom if differs- // (e.g., 'month' zoom will default to 'month' interval)- // TODO: investigate how to handle this page update better - this limits functionality when in tour mode- if (isTourActive) {- if (timeScale !== prevProps.timeScale && prevProps.timeScaleChangeUnit !== timeScale) {- if (timeScale !== timeScaleChangeUnit && !customSelected) {- this.props.selectInterval(deltaChangeAmt, timeScaleToNumberKey[timeScale], false);- }- }- }}/**@@ -733,14 +718,7 @@ class Timeline extends React.Component {}componentDidMount() {- let {- timeScale,- timeScaleChangeUnit,- deltaChangeAmt,- customSelected,- updateAppNow,- selectInterval- } = this.props;+ let { updateAppNow } = this.props;document.addEventListener('keydown', this.handleKeyDown);document.addEventListener('keyup', this.handleKeyUp);@@ -753,11 +731,6 @@ class Timeline extends React.Component {// update application relative every 10 minutes from component mountthis.appNowUpdateInterval = setInterval(() => updateAppNow(new Date()), 600000);this.setInitialState();-- // update interval selectedzoom level as default- if (timeScale !== timeScaleChangeUnit && !customSelected) {- selectInterval(deltaChangeAmt, timeScaleToNumberKey[timeScale], false);- }}componentWillUnmount() {diff --git a/web/js/modules/date/util.js b/web/js/modules/date/util.jsindex 72aba02d9..d96632af5 100644--- a/web/js/modules/date/util.js+++ b/web/js/modules/date/util.js@@ -1,6 +1,7 @@import util from '../../util/util';import { each as lodashEach, get } from 'lodash';import update from 'immutability-helper';+import { timeScaleFromNumberKey, timeScaleToNumberKey } from './constants';export function serializeDate(date) {return (@@ -51,7 +52,18 @@ export function mapLocationToDateState(config) {const appNow = get(state, 'date.appNow');+ const interval =+ get(stateFromLocation, 'date.interval') || get(state, 'date.interval');+ const selectedZoom =+ get(stateFromLocation, 'date.selectedZoom') ||+ get(state, 'date.selectedZoom');+ const isCustom =+ get(stateFromLocation, 'date.customSelected') ||+ get(state, 'date.customSelected');+ const timeScaleChangeUnit = timeScaleFromNumberKey[interval];+ const timeScale = timeScaleFromNumberKey[selectedZoom.toString()];// legacy time permalink+if (parameters.time && !parameters.t && appNow) {const date = tryCatchDate(parameters.time, appNow);if (date && date !== appNow) {@@ -62,5 +74,18 @@ export function mapLocationToDateState(});}}+ // update interval selectedzoom level as default interval+ if (timeScale !== timeScaleChangeUnit && !isCustom) {+ const defaultValues = {+ interval: timeScaleToNumberKey[timeScale],+ delta: 1,+ customSelected: false+ };+ stateFromLocation = update(stateFromLocation, {+ date: {+ $merge: defaultValues+ }+ });+ }return stateFromLocation;}