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/folders.js | 2 +- client/reducers/tasks.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'client/reducers') diff --git a/client/reducers/folders.js b/client/reducers/folders.js index e77c954..6731758 100644 --- a/client/reducers/folders.js +++ b/client/reducers/folders.js @@ -44,7 +44,7 @@ const folders = (state = {}, action) => { folder = action.folder folder_id = folder.id if (openFolders.indexOf(folder.id) === -1) { - openFolders = openFolders.concat(folder.id) + openFolders = [folder.id].concat(openFolders || []) localStorage['openFolders'] = JSON.stringify(openFolders) } filesAreLoaded = state.folders.some( (folder) => { 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