Listen to folder added event

pull/5370/head
ioedeveloper 4 years ago committed by yann300
parent f061006ffc
commit d2968f9493
  1. 3
      src/app/files/file-explorer.js
  2. 17
      src/app/files/remixDProvider.js

@ -130,11 +130,8 @@ function fileExplorer (localRegistry, files, menuItems) {
function folderAdded (folderpath) {
self.ensureRoot(() => {
console.log('called: ensureRoot')
folderpath = folderpath.split('/').slice(0, -1).join('/')
console.log('folderpath: ', folderpath)
self.files.resolveDirectory(folderpath, (error, fileTree) => {
console.log('fileTree: ', fileTree)
if (error) console.error(error)
if (!fileTree) return
fileTree = normalize(folderpath, fileTree)

@ -22,6 +22,11 @@ module.exports = class RemixDProvider {
})
})
this._appManager.on('remixd', 'folderAdded', (path) => {
console.log('event listener called')
this.event.trigger('folderAdded', [path])
})
this._appManager.on('remixd', 'notified', (data) => {
if (data.scope === 'sharedfolder') {
if (data.name === 'created') {
@ -110,21 +115,12 @@ module.exports = class RemixDProvider {
async set (path, content, cb) {
const unprefixedpath = this.removePrefix(path)
const exists = await this.exists(path)
return this._appManager.call('remixd', 'set', { path: unprefixedpath, content: content }).then(async (result) => {
if (cb) return cb(null, result)
const path = this.type + '/' + unprefixedpath
if (!exists) {
const isDirectory = await this.isDirectory(path)
if (isDirectory) this.event.trigger('folderAdded', [path])
else this.event.trigger('fileAdded', [path])
} else {
this.event.trigger('fileChanged', [path])
}
if (cb) return cb(null, result)
}).catch((error) => {
if (cb) return cb(error)
throw new Error(error)
@ -192,7 +188,6 @@ module.exports = class RemixDProvider {
if (!path) return callback(null, { [self.type]: { } })
const unprefixedpath = this.removePrefix(path)
this._appManager.call('remixd', 'resolveDirectory', { path: unprefixedpath }).then((result) => {
console.log('result: ', result)
callback(null, result)
}).catch(callback)
}

Loading…
Cancel
Save