diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-07-21 04:48:52 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-07-21 04:48:52 +0200 |
| commit | d41070c7b00fafc974a1a6e7b6d1b42391fa57ed (patch) | |
| tree | 4178eba89627e8581cdc5eea65bf7f11591f6b45 /client/reducers/tasks.js | |
| parent | d02cbad01f3abfa8a1aad0b55b8bd9cf544090cf (diff) | |
all async paths working
Diffstat (limited to 'client/reducers/tasks.js')
| -rw-r--r-- | client/reducers/tasks.js | 14 |
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 |
