summaryrefslogtreecommitdiff
path: root/client/reducers
diff options
context:
space:
mode:
Diffstat (limited to 'client/reducers')
-rw-r--r--client/reducers/folders.js2
-rw-r--r--client/reducers/tasks.js14
2 files changed, 11 insertions, 5 deletions
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