import types from '../../types' const samplernnInitialState = { loading: true, error: null, folders: [], folder: {}, data: null, lossReport: null, } const samplernnReducer = (state = samplernnInitialState, action) => { 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, } case types.file.create: if (state.folder.id === action.data.folder_id) { return { ...state, files: [action.data].concat(state.files), } } return state case types.folder.upload_complete: if (state.folder.id === action.folder) { return { ...state, files: [action.files].concat(state.files), } } 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