diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 20:12:25 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 20:12:25 +0200 |
| commit | 9fa57ffa48ac558b482010c1e96bdb6e5967c1e5 (patch) | |
| tree | b464cd78ad37ce047cc818e864e4cfd1a619622b /app/client/modules/samplernn/samplernn.reducer.js | |
| parent | d3705a588e3a790868082dbf9590163b8016a94c (diff) | |
ref folder in main dir
Diffstat (limited to 'app/client/modules/samplernn/samplernn.reducer.js')
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index a41894f..90e052c 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -5,7 +5,7 @@ const samplernnInitialState = { progress: { i: 0, n: 0 }, error: null, folders: [], - folder: {}, + folder_id: 0, data: null, lossReport: null, } @@ -47,7 +47,7 @@ const samplernnReducer = (state = samplernnInitialState, action) => { folders: state.data.folders.concat([action.data.id]), folderLookup: { ...state.data.folderLookup, - [...action.data.id]: action.data, + [action.data.id]: action.data, } }, folder: { @@ -60,35 +60,72 @@ const samplernnReducer = (state = samplernnInitialState, action) => { return state case types.file.create: - if (state.folder.id === action.data.folder_id) { + if (action.data.module === 'samplernn') { console.log(action.data, state.folder) + // const dataset = { + // name, + // input: [], + // checkpoints: [], + // output: [], + // } + let dataset, old_dataset, folder, old_folder + const dataset_name = action.data.name.split('.')[0] + if (dataset_name in state.data.datasets) { + old_dataset = state.data.datasets[dataset_name] + dataset = { + ...old_dataset, + input: action.data.generated ? old_dataset.input : [action.data.id].concat(old_dataset.input), + output: !action.data.generated ? old_dataset.output : [action.data.id].concat(old_dataset.output), + } + } else { + dataset = { + name: dataset_name, + date: action.data.created_at || action.data.date, + input: action.data.generated ? [] : [action.data.id], + checkpoints: [], + output: !action.data.generated ? [] : [action.data.id], + } + } + old_folder = state.data.folderLookup[action.data.folder_id] + folder = { + ...old_folder, + files: old_folder.files.concat[action.data.id] + } return { ...state, loading: false, data: { + ...state.data, files: state.data.files.concat([action.data.id]), + folderLookup: { + ...state.data.folderLookup, + [action.data.folder_id]: folder, + }, + fileLookup: { + ...state.data.fileLookup, + [action.data.id]: action.data, + }, + datasetLookup: { + ...state.data.datasetLookup, + [dataset_name]: dataset, + }, + } + } + } + return state + + case types.file.update: + if (action.data.module === 'samplernn') { + return { + ...state, + loading: false, + data: { + ...state.data, fileLookup: { ...state.data.fileLookup, - [...action.data.id]: action.data, + [action.data.id]: action.data, } } - folder: { - ...state.folder, - files: [ - ...state.folder.files, - action.data, - ], - datasets: [ - ...state.folder.datasets, - { - name: action.data.name, - date: action.data.date, - input: [action.data].concat(state.folder.input), - output: [], - checkpoints: [], - } - ], - }, } } return state @@ -112,7 +149,7 @@ const samplernnReducer = (state = samplernnInitialState, action) => { case types.samplernn.set_folder: return { ...state, - folder: action.folder, + folder_id: action.folder_id, } case types.samplernn.load_loss: |
