From 775662af6ac170d7b8950ba55d6bf42204602cf1 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 4 May 2018 22:30:11 +0200 Subject: [PATCH] Activities: empty gpx data --- mpwo_client/src/actions/activities.js | 7 ++++++- mpwo_client/src/components/Activities/ActivityMap.jsx | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mpwo_client/src/actions/activities.js b/mpwo_client/src/actions/activities.js index 14141455..28744ccb 100644 --- a/mpwo_client/src/actions/activities.js +++ b/mpwo_client/src/actions/activities.js @@ -23,7 +23,8 @@ export function addActivity(form) { } export function getActivityGpx(activityId) { - return function(dispatch) { + if (activityId) { + return function(dispatch) { return mpwoApi .getActivityGpx(activityId) .then(ret => { @@ -34,5 +35,9 @@ export function getActivityGpx(activityId) { } }) .catch(error => dispatch(setError(`activities: ${error}`))) + } + } + return function(dispatch) { + dispatch(setGpx(null)) } } diff --git a/mpwo_client/src/components/Activities/ActivityMap.jsx b/mpwo_client/src/components/Activities/ActivityMap.jsx index b0c43773..d5bee736 100644 --- a/mpwo_client/src/components/Activities/ActivityMap.jsx +++ b/mpwo_client/src/components/Activities/ActivityMap.jsx @@ -18,6 +18,10 @@ class ActivityMap extends React.Component { this.props.loadActivityGpx(this.props.activity.id) } + componentWillUnmount() { + this.props.loadActivityGpx(null) + } + render() { const { gpxContent } = this.props const { jsonData, bounds } = getGeoJson(gpxContent)