diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index e7eb5cee01..770e626ff8 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -228,14 +228,23 @@ function fileExplorer (appAPI, files) { } } +fileExplorer.prototype.hide = function () { + if (this.container) this.container.style.display = 'none' +} + +fileExplorer.prototype.show = function () { + if (this.container) this.container.style.display = 'block' +} + fileExplorer.prototype.init = function () { this.container = yo`
` return this.container } fileExplorer.prototype.ensureRoot = function (cb) { + cb = cb || (() => {}) var self = this - if (self.element && cb) return cb() + if (self.element) return cb() self.files.resolveDirectory('/', (error, files) => { if (error) console.error(error) diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index e632ca2f1f..621a8811a2 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -89,7 +89,6 @@ function filepanel (appAPI, filesProvider) { 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) => { websocketconn.style.color = styles.colors.yellow @@ -99,22 +98,19 @@ function filepanel (appAPI, filesProvider) { filesProvider['localhost'].remixd.event.register('connected', (event) => { websocketconn.style.color = styles.colors.green websocketconn.setAttribute('title', 'Connected to localhost. ' + JSON.stringify(event)) + fileSystemExplorer.show() }) filesProvider['localhost'].remixd.event.register('errored', (event) => { websocketconn.style.color = styles.colors.red websocketconn.setAttribute('title', 'localhost connection errored. ' + JSON.stringify(event)) - if (fileSystemExplorer.element && containerFileSystem.children.length > 0) { - containerFileSystem.removeChild(fileSystemExplorer.element) - } + fileSystemExplorer.hide() }) filesProvider['localhost'].remixd.event.register('closed', (event) => { websocketconn.style.color = styles.colors.black websocketconn.setAttribute('title', 'localhost connection closed. ' + JSON.stringify(event)) - if (fileSystemExplorer.element && containerFileSystem.children.length > 0) { - containerFileSystem.removeChild(fileSystemExplorer.element) - } + fileSystemExplorer.hide() }) fileExplorer.events.register('focus', function (path) {