fix file added

pull/1/head
yann300 7 years ago
parent a0ef64abef
commit d51d6b8d96
  1. 23
      src/app/files/file-explorer.js

@ -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) {
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()
}) })
} }

Loading…
Cancel
Save