import types from '../../types' const samplernnInitialState = { loading: true, error: null, folders: [], folder: {}, data: null, lossReport: null, } const samplernnReducer = (state = samplernnInitialState, action) => { // console.log(action.type) switch(action.type) { case types.samplernn.init: return { ...state, loading: false, data: action.data, } case types.socket.connect: return { ...state, } case types.task.task_begin: return { ...state, } case types.task.task_finish: return { ...state, } // so now the last thing is to figure out how to access things inside these datasets // and rebuild them if need be, considering this is SUPER awkward inside of redux. case types.folder.create: if (action.data.module === 'samplernn') { return { ...state, loading: false, // folder: { // ...action.data, // input: [], // checkpoints: [], // output: [], // } } } return state case types.file.create: if (state.folder.id === action.data.folder_id) { console.log(action.data, state.folder) return { ...state, loading: false, folder: { ...state.folder, datasets: [ ...state.folder.datasets, { name: action.data.name, date: action.data.date, input: [action.data].concat(state.folder.input), output: [], checkpoints: [], } ], }, } } return state case types.folder.upload_complete: if (state.folder.id === action.folder) { return { ...state, loading: false, folder: { ...state.folder, input: [action.data].concat(state.folder.input), }, } } return state case types.socket.status: return samplernnSocket(state, action.data) case types.samplernn.set_folder: return { ...state, folder: action.folder, } case types.samplernn.load_loss: return { ...state, lossReport: action.lossReport, } default: return state } } const samplernnSocket = (state, action) => { console.log(action) switch (action.key) { case 'list_directory': return state default: return state } } export default samplernnReducer