Triggered removeFile event and removed old event listener

pull/11/head
ioedeveloper 4 years ago
parent c43b0ed5aa
commit 802927ef58
  1. 10
      apps/remix-ide/src/app/files/file-explorer.js
  2. 2
      apps/remix-ide/src/app/files/fileProvider.js
  3. 29
      apps/remix-ide/src/app/files/remixDProvider.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)
}
},
() => {}

@ -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

@ -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)

Loading…
Cancel
Save