From 7436f4960fea6e89ba356a0bdd323e19076edbf7 Mon Sep 17 00:00:00 2001 From: catarak Date: Wed, 14 Sep 2016 16:41:36 -0400 Subject: [PATCH] this time, db reformat, for real --- client/modules/IDE/pages/IDEView.js | 2 +- server/utils/db_reformat.js | 54 +++++++++++++---------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js index d0aa17ae..11a39e14 100644 --- a/client/modules/IDE/pages/IDEView.js +++ b/client/modules/IDE/pages/IDEView.js @@ -462,7 +462,7 @@ IDEView.propTypes = { function mapStateToProps(state) { return { files: state.files, - selectedFile: state.files.filter(file => file.isSelectedFile)[0], + selectedFile: state.files.find(file => file.isSelectedFile), htmlFile: getHTMLFile(state.files), jsFiles: getJSFiles(state.files), cssFiles: getCSSFiles(state.files), diff --git a/server/utils/db_reformat.js b/server/utils/db_reformat.js index 4b61f7c6..1b8cf358 100644 --- a/server/utils/db_reformat.js +++ b/server/utils/db_reformat.js @@ -87,36 +87,32 @@ Project.find({}) .exec((err, projects) => { projects.forEach((project, projectIndex) => { project.files.forEach((file) => { - // if (file.isSelected && !file.isSelectedFile) { - // file.isSelectedFile = file.isSelected; - // delete file.isSelected; - // } - - // if (file.name === 'sketch.js') { - // file.isSelectedFile = true; - // delete file.isSelected; - // console.log(file); - // // file.save((err, savedFile) => { - // // console.log('file saved'); - // // }); - // } else { - // file.isSelctedFile = false; - // } - // // console.log('project', projectIndex); - // // if (file.isSelected) { - // // console.log('is selected remains'); - // // } - - // // if (file.isSelctedFile) { - // // console.log('changed to isSelected file'); - // // } - // project.save((err, savedProject) => { - // console.log('project', projectIndex, 'is saved.'); - // }); - - if (file.fileType === 'folder' && file.isSelctedFile) { - console.log('there is an error'); + if (file.isSelected) { + delete file.isSelected; } + + if (file.name === 'sketch.js') { + file.isSelectedFile = true; + delete file.isSelected; + console.log(file); + // file.save((err, savedFile) => { + // console.log('file saved'); + // }); + } else { + file.isSelectedFile = false; + } + // console.log('project', projectIndex); + // if (file.isSelected) { + // console.log('is selected remains'); + // } + + // if (file.isSelctedFile) { + // console.log('changed to isSelected file'); + // } + project.save((err, savedProject) => { + console.log('project', projectIndex, 'is saved.'); + }); + }); }); });