Interactive interface for browsing global, full-resolution satellite imagery
account for legacy time parameter #1834
Benjamin King109a8146f527
diff --git a/web/js/location.js b/web/js/location.jsindex 75bad03a9..a53528afd 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -2,7 +2,7 @@ import { assign as lodashAssign, get } from 'lodash';import { encode } from './modules/link/util';// legacy crutches// import { getLayersParameterSetup } from './modules/layers/util';-import { serializeDate, tryCatchDate } from './modules/date/util';+import { serializeDate, tryCatchDate, mapLocationToDateState } from './modules/date/util';import {checkTourBuildTimestamp,mapLocationToTourState@@ -41,7 +41,11 @@ export const mapLocationToState = (state, location) => {if (location.search) {let parameters = util.fromQueryString(location.search);let stateFromLocation = location.query;-+ stateFromLocation = mapLocationToDateState(+ parameters,+ stateFromLocation,+ state+ );stateFromLocation = mapLocationToProjState(parameters,stateFromLocation,diff --git a/web/js/modules/date/util.js b/web/js/modules/date/util.jsindex 449478487..07670c5e3 100644--- a/web/js/modules/date/util.js+++ b/web/js/modules/date/util.js@@ -1,5 +1,6 @@import util from '../../util/util';-import { each as lodashEach } from 'lodash';+import { each as lodashEach, get } from 'lodash';+import update from 'immutability-helper';export function serializeDate(date) {return (@@ -43,3 +44,21 @@ export function getLayersActiveAtDate(layers, date) {});return arra;}+export function mapLocationToDateState(+ parameters,+ stateFromLocation,+ state,+ config+) {+ const appNow = get(state, 'date.appNow');+ // legacy time permalink+ if (parameters.time && !parameters.t && appNow) {+ const date = tryCatchDate(parameters.time, appNow);+ stateFromLocation = update(stateFromLocation, {+ date: {+ selected: { $set: date }+ }+ });+ }+ return stateFromLocation;+}