diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 15:40:56 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 15:40:56 +0200 |
| commit | e243e4f65cc2c98724a1cfb4d28ac5f1d1bc0a79 (patch) | |
| tree | b843eed4b0a39d58b1feeaf9a2f44182867cccf5 /app/client/modules/samplernn/samplernn.reducer.js | |
| parent | ba825eb101f8ca1cbf5de7a87c6c2995a0d687a5 (diff) | |
api events over bridge
Diffstat (limited to 'app/client/modules/samplernn/samplernn.reducer.js')
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index c271407..5255ca3 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -63,7 +63,19 @@ const samplernnReducer = (state = samplernnInitialState, action) => { if (action.data.module === 'samplernn') { console.log(action.data) let dataset, old_dataset, folder, old_folder - const dataset_name = action.data.name.split('.')[0] + let dataset_name + if (action.data.dataset) { + dataset_name = action.data.dataset + } + else if (action.data.name) { + dataset_name = action.data.name.split('.')[0] + } + else if (action.data.url) { + dataset_name = action.data.url + } + else { + dataset_name = null + } if (dataset_name in state.data.datasetLookup) { old_dataset = state.data.datasetLookup[dataset_name] dataset = { @@ -112,15 +124,42 @@ const samplernnReducer = (state = samplernnInitialState, action) => { case types.file.update: if (action.data.module === 'samplernn') { + let old_dataset; + let new_dataset = state.data.datasetLookup[action.data.dataset] + let old_file = state.data.fileLookup[action.data.id] + let new_dataset_update; + if (old_file && action.data.dataset !== old_file.dataset) { + if (state.data.datasetLookup[old_file.dataset]) { + old_dataset = state.data.datasetLookup[old_file.dataset] + old_dataset_update = { + ...old_dataset, + input: old_dataset.input.filter(id => id !== action.data.id), + output: old_dataset.output.filter(id => id !== action.data.id), + } + } + new_dataset_update = { + ...new_dataset, + input: action.data.generated ? [] : [action.data.id], + output: !action.data.generated ? [] : [action.data.id], + } + } return { ...state, loading: false, data: { ...state.data, + datasetLookup: old_dataset ? { + ...state.data.datasetLookup, + [old_dataset.name]: old_dataset_update, + [new_dataset.name]: new_dataset_update, + } : new_dataset_update ? { + ...state.data.datasetLookup, + [new_dataset.name]: new_dataset_update, + } : state.data.datasetLookup, fileLookup: { ...state.data.fileLookup, [action.data.id]: action.data, - } + }, } } } |
