From d41070c7b00fafc974a1a6e7b6d1b42391fa57ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Jul 2017 04:48:52 +0200 Subject: all async paths working --- client/reducers/tasks.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'client/reducers/tasks.js') 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 -- cgit v1.2.3-70-g09d2