summaryrefslogtreecommitdiff
path: root/client/reducers
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-19 00:50:05 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-19 00:50:05 +0200
commit64e8c03dea044752bf3f2f228462721fe565f950 (patch)
tree41b48b67f69979bfc97be166129ee41c8dcb0c7f /client/reducers
parent11a70bc347587219b2ec7b63cf4a6ff69bb4199b (diff)
refactor all the worker stuff
Diffstat (limited to 'client/reducers')
-rw-r--r--client/reducers/currentTask.js11
-rw-r--r--client/reducers/folders.js2
-rw-r--r--client/reducers/tasks.js13
3 files changed, 18 insertions, 8 deletions
diff --git a/client/reducers/currentTask.js b/client/reducers/currentTask.js
index e760fba..126c35d 100644
--- a/client/reducers/currentTask.js
+++ b/client/reducers/currentTask.js
@@ -23,18 +23,15 @@ const currentTask = (state = {}, action) => {
content_file_id: state.content.id,
style_file_id: state.style.id,
alpha: state.alpha || '0.001',
- command: 'nsatf.py',
+ tool: 'nsatf',
completed: false,
}
client.task.create( record ).then( (data) => {
- addTask( data )
+ data.content_file = state.content
+ data.style_file = state.file
+ // store.dispatch( addTask( data ) )
})
-
return state
-// case 'ADD_TASK':
-// return {
-// ...state
-// }
default:
return state
}
diff --git a/client/reducers/folders.js b/client/reducers/folders.js
index d6bdd46..a69df74 100644
--- a/client/reducers/folders.js
+++ b/client/reducers/folders.js
@@ -90,6 +90,7 @@ const folders = (state = {}, action) => {
...state,
folders
}
+
case 'UPDATE_FILE':
file = action.file
folders = state.folders.map( (folder) => {
@@ -106,6 +107,7 @@ const folders = (state = {}, action) => {
...state,
folders: folders
}
+
default:
return state
}
diff --git a/client/reducers/tasks.js b/client/reducers/tasks.js
index d6ef8e1..9edd82a 100644
--- a/client/reducers/tasks.js
+++ b/client/reducers/tasks.js
@@ -1,10 +1,21 @@
// import { addTask } from '../actions'
import client from '../client'
-const tasks = (state = {}, action) => {
+const tasks = (state = [], action) => {
switch (action.type) {
case 'LOAD_TASKS':
return action.tasks
+ case 'ADD_TASK':
+ console.log(action)
+ return state.concat([action.task])
+ case 'TASK_UPDATED':
+ const updated_tasks = state.map(task => {
+ if (task.id == id) {
+ return task
+ }
+ return id
+ })
+ return updated_tasks
default:
return state
}