Trigger fileAdded, fileChanged and fileRemoved event

pull/262/head
ioedeveloper 4 years ago committed by yann300
parent 307f92f68c
commit 7f9dc0fc52
  1. 22
      src/app/files/remixDProvider.js
  2. 1
      src/app/ui/TreeView.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)

@ -152,7 +152,6 @@ class TreeView {
}
nodeAt (path) {
console.log('nodeAt path: ', path)
return this.view.querySelector(`ul[key="${path}"]`)
}

Loading…
Cancel
Save