diff --git a/fittrackee_client/src/actions/activities.js b/fittrackee_client/src/actions/activities.js index 997f1084..009bad1f 100644 --- a/fittrackee_client/src/actions/activities.js +++ b/fittrackee_client/src/actions/activities.js @@ -48,7 +48,10 @@ export const addActivity = form => dispatch => } dispatch(setLoading(false)) }) - .catch(error => dispatch(setError(`activities|${error}`))) + .catch(error => { + dispatch(setLoading(false)) + dispatch(setError(`activities|${error}`)) + }) export const addActivityWithoutGpx = form => dispatch => FitTrackeeGenericApi.addData('activities/no_gpx', form) @@ -150,7 +153,10 @@ export const editActivity = form => dispatch => } dispatch(setLoading(false)) }) - .catch(error => dispatch(setError(`activities|${error}`))) + .catch(error => { + dispatch(setLoading(false)) + dispatch(setError(`activities|${error}`)) + }) export const getMoreActivities = params => dispatch => FitTrackeeGenericApi.getData('activities', params) diff --git a/fittrackee_client/src/actions/index.js b/fittrackee_client/src/actions/index.js index 0fd33458..e4697585 100644 --- a/fittrackee_client/src/actions/index.js +++ b/fittrackee_client/src/actions/index.js @@ -25,7 +25,9 @@ export const setLoading = loading => ({ }) export const getOrUpdateData = (action, target, data) => dispatch => { + dispatch(setLoading(true)) if (data && data.id && isNaN(data.id)) { + dispatch(setLoading(false)) return dispatch(setError(`${target}|Incorrect id`)) } return FitTrackeeApi[action](target, data) @@ -35,8 +37,12 @@ export const getOrUpdateData = (action, target, data) => dispatch => { } else { dispatch(setError(`${target}|${ret.message || ret.status}`)) } + dispatch(setLoading(false)) + }) + .catch(error => { + dispatch(setLoading(false)) + dispatch(setError(`${target}|${error}`)) }) - .catch(error => dispatch(setError(`${target}|${error}`))) } export const addData = (target, data) => dispatch => diff --git a/fittrackee_client/src/components/Activities/ActivitiesList.jsx b/fittrackee_client/src/components/Activities/ActivitiesList.jsx index 32679845..de7dd650 100644 --- a/fittrackee_client/src/components/Activities/ActivitiesList.jsx +++ b/fittrackee_client/src/components/Activities/ActivitiesList.jsx @@ -7,7 +7,7 @@ import { getDateWithTZ } from '../../utils' export default class ActivitiesList extends React.PureComponent { render() { - const { activities, sports, t, user } = this.props + const { activities, loading, sports, t, user } = this.props return (