summaryrefslogtreecommitdiff
path: root/client/reducers/tasks.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/reducers/tasks.js')
-rw-r--r--client/reducers/tasks.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/client/reducers/tasks.js b/client/reducers/tasks.js
index 9c2b0b4..904c368 100644
--- a/client/reducers/tasks.js
+++ b/client/reducers/tasks.js
@@ -1,6 +1,8 @@
import client from '../client'
const tasks = (state = [], action) => {
+ let updated_tasks;
+
switch (action.type) {
case 'LOAD_TASKS':
return action.tasks
@@ -9,13 +11,17 @@ const tasks = (state = [], action) => {
return [action.task].concat(state)
case 'UPDATE_TASK':
- const updated_tasks = state.map(task => {
- if (task.id == id) {
- return task
+ updated_tasks = state.map(task => {
+ if (task.id === action.task.id) {
+ return action.task
}
- return id
+ return task
})
return updated_tasks
+
+ case 'CANCEL_TASK':
+ client.task.destroy(action.task)
+ return state.filter(task => task !== action.task)
default:
return state