summaryrefslogtreecommitdiff
path: root/app/client/modules/biggan/biggan.reducer.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-12-18 21:13:05 +0100
committerJules Laplace <julescarbon@gmail.com>2019-12-18 21:13:05 +0100
commitfe8ab6133a31284d94944f5d75da9d6ad2b2bdb9 (patch)
tree6b73b14bd88b64868d776b481d2aca0feb453c9c /app/client/modules/biggan/biggan.reducer.js
parent3a432e15399bd756cdeef376b46ae2968559790c (diff)
adding biggan
Diffstat (limited to 'app/client/modules/biggan/biggan.reducer.js')
-rw-r--r--app/client/modules/biggan/biggan.reducer.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/client/modules/biggan/biggan.reducer.js b/app/client/modules/biggan/biggan.reducer.js
new file mode 100644
index 0000000..a0c9842
--- /dev/null
+++ b/app/client/modules/biggan/biggan.reducer.js
@@ -0,0 +1,43 @@
+import types from '../../types'
+import datasetReducer from '../../dataset/dataset.reducer'
+
+const bigganInitialState = {
+ loading: true,
+ progress: { i: 0, n: 0 },
+ error: null,
+ folder_id: 0,
+ data: null,
+ results: null,
+ checkpoint: {
+ name: '',
+ sequenceCount: 0,
+ datasetCount: 0,
+ }
+}
+
+const bigganReducer = (state = bigganInitialState, action) => {
+ if (action.data && action.data.module === 'biggan') {
+ state = datasetReducer(state, action)
+ }
+
+ switch (action.type) {
+ case types.biggan.load_results:
+ return {
+ ...state,
+ results: action.results,
+ }
+ case types.file.destroy:
+ console.log('file destroy', state.results)
+ return {
+ ...state,
+ results: {
+ ...state.results,
+ files: state.results.files.filter(f => f.id !== action.data.id)
+ }
+ }
+ default:
+ return state
+ }
+}
+
+export default bigganReducer