Skip to content

Commit

Permalink
Removing redundant action
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday committed Jun 6, 2018
1 parent 022faaa commit 9153ddb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/js/components/Tasks/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export default {
this.isToggleLoading = true
this.error = null
this.$store.dispatch('toggleCompleted', this.task)
this.$store.dispatch('updateTask', {
task: this.task,
form: { is_completed: !this.task.is_completed }
})
.then(() => {
this.isToggleLoading = false
})
Expand Down
13 changes: 0 additions & 13 deletions src/js/store/modules/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@ const actions = {
})
},

toggleCompleted ({ commit }, task) {
return new Promise((resolve, reject) => {
axios.patch(state.endpoint + task.id, {is_completed: !task.is_completed})
.then(({ data }) => {
commit('updateTask', data.data)
resolve()
})
.catch(error => {
reject(error)
})
})
},

updateTask ({ commit }, {task, form}) {
return new Promise((resolve, reject) => {
axios.patch(state.endpoint + task.id, form)
Expand Down

0 comments on commit 9153ddb

Please sign in to comment.