diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 0af4b26871..2e43d70533 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -141,10 +141,14 @@ function fileExplorer (localRegistry, files, menuItems) { } function fileRemoved (filepath) { - var label = self.treeView.labelAt(filepath) + const label = self.treeView.labelAt(filepath) + filepath = filepath.split('/').slice(0, -1).join('/') + if (label && label.parentElement) { label.parentElement.removeChild(label) } + + self.updatePath(filepath) } function fileRenamed (oldName, newName, isFolder) { @@ -240,8 +244,6 @@ function fileExplorer (localRegistry, files, menuItems) { if (!removeFolder) { tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`) - } else { - self.updatePath(self.files.type) } }, () => {}) } @@ -284,8 +286,6 @@ function fileExplorer (localRegistry, files, menuItems) { if (!removeFile) { tooltip(`Failed to remove file ${key}.`) - } else { - self.updatePath(self.files.type) } }, () => {} diff --git a/src/app/files/fileProvider.js b/src/app/files/fileProvider.js index 3aea464e8f..1b02dd398b 100644 --- a/src/app/files/fileProvider.js +++ b/src/app/files/fileProvider.js @@ -180,6 +180,7 @@ class FileProvider { // folder is empty window.remixFileSystem.rmdirSync(path, console.log) } + this.event.trigger('fileRemoved', [this._normalizePath(path)]) } } catch (e) { console.log(e) @@ -222,7 +223,6 @@ class FileProvider { window.remixFileSystem.readdir(path, (error, files) => { var ret = {} - console.log('files: ', files) if (files) { files.forEach(element => { const absPath = (path === '/' ? '' : path) + '/' + element diff --git a/src/app/files/remixDProvider.js b/src/app/files/remixDProvider.js index e409ff9305..e4c5f14c0e 100644 --- a/src/app/files/remixDProvider.js +++ b/src/app/files/remixDProvider.js @@ -37,33 +37,6 @@ module.exports = class RemixDProvider { this._appManager.on('remixd', 'fileRemoved', (path) => { this.event.trigger('fileRemoved', [this.addPrefix(path)]) }) - - this._appManager.on('remixd', 'notified', (data) => { - if (data.scope === 'sharedfolder') { - if (data.name === 'created') { - this.init(() => { - this.event.trigger('fileAdded', [this.type + '/' + data.value.path, data.value.isReadOnly, data.value.isFolder]) - }) - } else if (data.name === 'removed') { - this.init(() => { - this.event.trigger('fileRemoved', [this.type + '/' + data.value.path]) - }) - } else if (data.name === 'changed') { - this._appManager.call('remixd', 'get', {path: data.value}, (error, content) => { - if (error) { - console.log(error) - } else { - var path = this.type + '/' + data.value - this.filesContent[path] = content - this.event.trigger('fileExternallyChanged', [path, content]) - } - }) - } else if (data.name === 'rootFolderChanged') { - // new path has been set, we should reset - this.event.trigger('folderAdded', [this.type + '/']) - } - } - }) } isConnected () { @@ -199,7 +172,7 @@ module.exports = class RemixDProvider { if (path[0] === '/') path = path.substring(1) if (!path) return callback(null, { [self.type]: { } }) const unprefixedpath = this.removePrefix(path) - console.log('unprefixedpath: ', unprefixedpath) + this._appManager.call('remixd', 'resolveDirectory', { path: unprefixedpath }).then((result) => { callback(null, result) }).catch(callback)