From d2968f949315f3c2455aa3d29033d321887e8d98 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 19 Jun 2020 04:57:40 +0100 Subject: [PATCH] Listen to folder added event --- src/app/files/file-explorer.js | 3 --- src/app/files/remixDProvider.js | 19 +++++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 38687b2310..0af4b26871 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.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) diff --git a/src/app/files/remixDProvider.js b/src/app/files/remixDProvider.js index bb05133d0d..09f201a10b 100644 --- a/src/app/files/remixDProvider.js +++ b/src/app/files/remixDProvider.js @@ -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) + this.event.trigger('fileChanged', [path]) }).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) }