diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js old mode 100755 new mode 100644 index 75b38ad932..afac4b3382 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -383,18 +383,22 @@ function removeSubtree (files, path, isFolder) { } fileExplorer.prototype.init = function () { + this.container = yo`
` + return this.container +} + +fileExplorer.prototype.ensureRoot = function (cb) { var self = this + if (self.element && cb) return cb() + self.files.resolveDirectory('/', (error, files) => { if (error) console.error(error) - var element = self.treeView.render(files) + var element = self.treeView.render(files, false) element.className = css.fileexplorer element.events = self.events element.api = self.api - setTimeout(function () { - self.element.parentElement.replaceChild(element, self.element) + self.container.appendChild(element) self.element = element - }, 0) + if (cb) cb() }) - self.element = yo`
` - return self.element } diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index 1547f66896..55a8f4e355 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -73,7 +73,7 @@ function filepanel (appAPI, filesProvider) {
${fileExplorer.init()}
-
+
${fileSystemExplorer.init()}
${swarmExplorer.init()}
${githubExplorer.init()}
${gistExplorer.init()}
@@ -87,7 +87,7 @@ function filepanel (appAPI, filesProvider) { var event = new EventManager() self.event = event var element = template() - + fileExplorer.ensureRoot() var containerFileSystem = element.querySelector('.filesystemexplorer') var websocketconn = element.querySelector('.websocketconn') filesProvider['localhost'].remixd.event.register('connecting', (event) => { @@ -200,7 +200,6 @@ function filepanel (appAPI, filesProvider) { * @param {String} txHash - hash of the transaction */ function connectToLocalhost () { - var container = document.querySelector('.filesystemexplorer') if (filesProvider['localhost'].isConnected()) { filesProvider['localhost'].close((error) => { if (error) console.log(error) @@ -213,10 +212,7 @@ function filepanel (appAPI, filesProvider) { if (error) { console.log(error) } else { - if (fileSystemExplorer.element && container.children.length > 0) { - container.removeChild(fileSystemExplorer.element) - } - container.appendChild(fileSystemExplorer.init()) + fileSystemExplorer.ensureRoot() } }) }})