From 3362d0a5ad4808617993b904d698eb35cf6cf737 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 4 Jun 2018 20:26:09 +0200 Subject: fix progress --- app/client/common/fileList.component.js | 4 ++-- app/client/modules/samplernn/samplernn.actions.js | 1 + app/client/modules/samplernn/samplernn.reducer.js | 21 +++++++++------------ app/client/util/index.js | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) (limited to 'app/client') 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 (
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 -- cgit v1.2.3-70-g09d2