diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 20:26:09 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 20:26:09 +0200 |
| commit | 3362d0a5ad4808617993b904d698eb35cf6cf737 (patch) | |
| tree | ac4a1f4d76cd4fe2e81b2bc756f077798928b88e /app/client | |
| parent | 2289265cdf7fda841e83882c602f3020c75de37c (diff) | |
fix progress
Diffstat (limited to 'app/client')
| -rw-r--r-- | app/client/common/fileList.component.js | 4 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 1 | ||||
| -rw-r--r-- | app/client/modules/samplernn/samplernn.reducer.js | 21 | ||||
| -rw-r--r-- | app/client/util/index.js | 4 |
4 files changed, 14 insertions, 16 deletions
diff --git a/app/client/common/fileList.component.js b/app/client/common/fileList.component.js index 0e6c402..80de6b2 100644 --- a/app/client/common/fileList.component.js +++ b/app/client/common/fileList.component.js @@ -19,7 +19,7 @@ export const FileList = props => { } = props const { mapFn, sortFn } = util.sort.orderByFn(orderBy) const fileList = (files || []) - // .filter(f => !!f) + .filter(f => !!f) .map(mapFn) .sort(sortFn) .map(pair => { @@ -31,7 +31,7 @@ export const FileList = props => { onClick={onClick} /> }) - if (! (files && files.length)) { + if (!fileList || !fileList.length) { return ( <div className={'rows ' + className}> <div class='row heading'> diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index c87718d..a6c8ab8 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -9,6 +9,7 @@ import { allProgress } from '../../util' export const load_directories = (id) => (dispatch) => { // console.log(actions) + dispatch({ type: types.app.load_progress, progress: { i: 0, n: 7 }}) allProgress([ actions.folder.index({ module: 'samplernn' }), actions.file.index({ module: 'samplernn' }), diff --git a/app/client/modules/samplernn/samplernn.reducer.js b/app/client/modules/samplernn/samplernn.reducer.js index 90e052c..7335b21 100644 --- a/app/client/modules/samplernn/samplernn.reducer.js +++ b/app/client/modules/samplernn/samplernn.reducer.js @@ -60,14 +60,9 @@ const samplernnReducer = (state = samplernnInitialState, action) => { return state case types.file.create: + case types.folder.upload_complete: 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) { @@ -130,15 +125,17 @@ const samplernnReducer = (state = samplernnInitialState, action) => { } return state - case types.folder.upload_complete: - if (state.folder.id === action.folder) { + case types.file.destroy: + if (action.data.module === 'samplernn') { + // delete + const { [action.data.id]: removedFile, ...fileLookup } = state.data.fileLookup return { ...state, loading: false, - folder: { - ...state.folder, - input: [action.data].concat(state.folder.input), - }, + data: { + ...state.data, + fileLookup, + } } } return state diff --git a/app/client/util/index.js b/app/client/util/index.js index 14d4d6f..c5eb8dd 100644 --- a/app/client/util/index.js +++ b/app/client/util/index.js @@ -26,8 +26,8 @@ export function randrange(a,b){ return Math.random() * (b-a) + a } document.body.style.backgroundImage = 'linear-gradient(' + (randint(40)+40) + 'deg, #fde, #ffe)' export const allProgress = (promises, progress_cb) => { - let d = 0; - progress_cb(0); + let d = 0 + progress_cb(0, 0, promises.length) promises.forEach((p) => { p.then((s) => { d += 1 |
