Commit d51d6b8d authored by yann300's avatar yann300

fix file added

parent a0ef64ab
...@@ -317,15 +317,20 @@ function fileExplorer (appAPI, files) { ...@@ -317,15 +317,20 @@ function fileExplorer (appAPI, files) {
} }
function fileAdded (filepath) { function fileAdded (filepath) {
var folderpath = filepath.split('/').slice(0, -1).join('/') self.ensureRoot(() => {
self.files.resolveDirectory(folderpath, (error, fileTree) => { var folderpath = filepath.split('/').slice(0, -1).join('/')
if (error) console.error(error)
if (!fileTree) return
fileTree = normalize(folderpath, fileTree)
var newTree = self.treeView.renderProperties(fileTree, false)
var currentTree = self.treeView.nodeAt(folderpath) var currentTree = self.treeView.nodeAt(folderpath)
currentTree.innerHTML = '' if (currentTree) {
;[...newTree.children].forEach(child => currentTree.appendChild(child)) self.files.resolveDirectory(folderpath, (error, fileTree) => {
if (error) console.error(error)
if (!fileTree) return
fileTree = normalize(folderpath, fileTree)
var newTree = self.treeView.renderProperties(fileTree, false)
currentTree.innerHTML = ''
;[...newTree.children].forEach(child => currentTree.appendChild(child))
})
}
}) })
} }
} }
...@@ -398,7 +403,7 @@ fileExplorer.prototype.ensureRoot = function (cb) { ...@@ -398,7 +403,7 @@ fileExplorer.prototype.ensureRoot = function (cb) {
element.events = self.events element.events = self.events
element.api = self.api element.api = self.api
self.container.appendChild(element) self.container.appendChild(element)
self.element = element self.element = element
if (cb) cb() if (cb) cb()
}) })
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment