From 357356f6e611ab15ebacadf6e5ecf516c04d2d3e Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Fri, 19 Jun 2020 13:45:43 +0100 Subject: [PATCH] Trigger fileAdded, fileChanged and fileRemoved event --- src/app/files/remixDProvider.js | 22 ++++++++++++++-------- src/app/ui/TreeView.js | 1 - 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/app/files/remixDProvider.js b/src/app/files/remixDProvider.js index 45ee1f2130..e409ff9305 100644 --- a/src/app/files/remixDProvider.js +++ b/src/app/files/remixDProvider.js @@ -23,10 +23,21 @@ module.exports = class RemixDProvider { }) this._appManager.on('remixd', 'folderAdded', (path) => { - console.log('event listener called') this.event.trigger('folderAdded', [this.addPrefix(path)]) }) + this._appManager.on('remixd', 'fileAdded', (path) => { + this.event.trigger('fileAdded', [this.addPrefix(path)]) + }) + + this._appManager.on('remixd', 'fileChanged', (path) => { + this.event.trigger('fileChanged', [this.addPrefix(path)]) + }) + + 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') { @@ -65,7 +76,7 @@ module.exports = class RemixDProvider { } init (cb) { - if (this._isReady) return cb() + if (this._isReady) return cb && cb() this._appManager.call('remixd', 'folderIsReadOnly', {}) .then((result) => { this._isReady = true @@ -118,9 +129,6 @@ module.exports = class RemixDProvider { return this._appManager.call('remixd', 'set', { path: unprefixedpath, content: content }).then(async (result) => { if (cb) return cb(null, result) - const path = this.type + '/' + unprefixedpath - - this.event.trigger('fileChanged', [path]) }).catch((error) => { if (cb) return cb(error) throw new Error(error) @@ -140,9 +148,7 @@ module.exports = class RemixDProvider { delete this.filesContent[path] resolve(true) - this.init(() => { - this.event.trigger('fileRemoved', [path]) - }) + this.init() }).catch(error => { if (error) console.log(error) resolve(false) diff --git a/src/app/ui/TreeView.js b/src/app/ui/TreeView.js index e2054b328e..6cb5bea2ad 100644 --- a/src/app/ui/TreeView.js +++ b/src/app/ui/TreeView.js @@ -152,7 +152,6 @@ class TreeView { } nodeAt (path) { - console.log('nodeAt path: ', path) return this.view.querySelector(`ul[key="${path}"]`) }