Merge branch 'master' into stats

This commit is contained in:
Sam 2019-01-04 18:41:58 +01:00
commit 1915c1f374
2 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,11 @@ export const pushActivities = activities => ({
activities,
})
export const removeActivity = activityId => ({
type: 'REMOVE_ACTIVITY',
activityId,
})
export const updateCalendar = activities => ({
type: 'UPDATE_CALENDAR',
activities,
@ -98,8 +103,9 @@ export const deleteActivity = id => dispatch => FitTrackeeGenericApi
.deleteData('activities', id)
.then(ret => {
if (ret.status === 204) {
Promise.resolve(dispatch(removeActivity(id))).then(() =>
dispatch(loadProfile())
history.push('/')
).then(() => history.push('/'))
} else {
dispatch(setError(`activities: ${ret.status}`))
}

View File

@ -25,6 +25,11 @@ const activities = (state = initial.activities, action) => {
...state,
data: state.data.concat(action.activities),
}
case 'REMOVE_ACTIVITY':
return {
...state,
data: state.data.filter(activity => activity.id !== action.activityId),
}
default:
return handleDataAndError(state, 'activities', action)
}