From aa3da2d744f86d8bd2c0d6e8c156eb95ace613b4 Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Tue, 8 Jan 2019 17:52:09 +0100 Subject: [PATCH] Add secure check to set map bounds with narrative --- src/reducers/app.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/reducers/app.js b/src/reducers/app.js index 2dd4832..3f9eb9c 100644 --- a/src/reducers/app.js +++ b/src/reducers/app.js @@ -52,10 +52,12 @@ function updateNarrative(appState, action) { if (stepTime < minTime) minTime = stepTime; if (stepTime > maxTime) maxTime = stepTime; - if (+step.longitude < cornerBound0[1]) cornerBound0[1] = +step.longitude; - if (+step.longitude > cornerBound1[1]) cornerBound1[1] = +step.longitude; - if (+step.latitude < cornerBound0[0]) cornerBound0[0] = +step.latitude; - if (+step.latitude > cornerBound1[0]) cornerBound1[0] = +step.latitude; + if (!!step.longitude && !!step.latitude) { + if (+step.longitude < cornerBound0[1]) cornerBound0[1] = +step.longitude; + if (+step.longitude > cornerBound1[1]) cornerBound1[1] = +step.longitude; + if (+step.latitude < cornerBound0[0]) cornerBound0[0] = +step.latitude; + if (+step.latitude > cornerBound1[0]) cornerBound1[0] = +step.latitude; + } }); minTime = new Date(minTime.getTime() - Math.abs((maxTime - minTime) / 10)); @@ -71,7 +73,7 @@ function updateNarrative(appState, action) { filters: { ...appState.filters, timerange: [minTime, maxTime], - mapBounds: [cornerBound0, cornerBound1] + mapBounds: (action.narrative) ? [cornerBound0, cornerBound1] : null } } }