From 3fbc033e37476ff03fc4ad93145976faeea47934 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 3 Jun 2018 16:34:09 +0200 Subject: reload the whole page. easier --- app/client/modules/samplernn/samplernn.datasets.js | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'app/client/modules/samplernn/samplernn.datasets.js') diff --git a/app/client/modules/samplernn/samplernn.datasets.js b/app/client/modules/samplernn/samplernn.datasets.js index dafed79..52d4ebd 100644 --- a/app/client/modules/samplernn/samplernn.datasets.js +++ b/app/client/modules/samplernn/samplernn.datasets.js @@ -6,6 +6,7 @@ import * as util from '../../util' import * as samplernnActions from './samplernn.actions' import DatasetForm from '../../dataset/dataset.form' +import NewDatasetForm from '../../dataset/dataset.new' import { FileList, FileRow } from '../../common/fileList.component' class SampleRNNDatasets extends Component { @@ -14,13 +15,14 @@ class SampleRNNDatasets extends Component { this.fileOptions = this.fileOptions.bind(this) this.pickFile = this.pickFile.bind(this) let id = props.match.params.id || localStorage.getItem('samplernn.last_id') - if (! id && props.location.pathname.match(/\/new\//)) { - id = 'new' - } else if (id) { + console.log('load dataset:', id) + if (id === 'new') return + if (id) { localStorage.setItem('samplernn.last_id', id) - } - if (id && (! props.samplernn.folder || props.samplernn.folder.id !== id)) { - props.actions.load_directories(id) + if (! props.samplernn.folder || props.samplernn.folder.id !== id) { + console.log('load directories') + props.actions.load_directories(id) + } } } pickFile(file){ @@ -50,16 +52,28 @@ class SampleRNNDatasets extends Component { ) } render(){ - const { samplernn } = this.props + const { samplernn, match, history } = this.props const folder = samplernn.folder - if (!folder || !folder.name) return + if (match.params.id === 'new') { + return + } + if (samplernn.loading) { + return Loading + } + if (!folder || !samplernn.data.folders.length) { + return history.push('/samplernn/datasets/new/') + } return (

{folder.name}

{folder.name !== 'unsorted' && - + } {this.renderDataset()}
-- cgit v1.2.3-70-g09d2