Trigger fileAdded, fileChanged and fileRemoved event

pull/11/head
ioedeveloper 5 years ago
parent 507ad94573
commit c43b0ed5aa
  1. 22
      apps/remix-ide/src/app/files/remixDProvider.js
  2. 1
      apps/remix-ide/src/app/ui/TreeView.js

@ -23,10 +23,21 @@ module.exports = class RemixDProvider {
}) })
this._appManager.on('remixd', 'folderAdded', (path) => { this._appManager.on('remixd', 'folderAdded', (path) => {
console.log('event listener called')
this.event.trigger('folderAdded', [this.addPrefix(path)]) 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) => { this._appManager.on('remixd', 'notified', (data) => {
if (data.scope === 'sharedfolder') { if (data.scope === 'sharedfolder') {
if (data.name === 'created') { if (data.name === 'created') {
@ -65,7 +76,7 @@ module.exports = class RemixDProvider {
} }
init (cb) { init (cb) {
if (this._isReady) return cb() if (this._isReady) return cb && cb()
this._appManager.call('remixd', 'folderIsReadOnly', {}) this._appManager.call('remixd', 'folderIsReadOnly', {})
.then((result) => { .then((result) => {
this._isReady = true this._isReady = true
@ -118,9 +129,6 @@ module.exports = class RemixDProvider {
return this._appManager.call('remixd', 'set', { path: unprefixedpath, content: content }).then(async (result) => { return this._appManager.call('remixd', 'set', { path: unprefixedpath, content: content }).then(async (result) => {
if (cb) return cb(null, result) if (cb) return cb(null, result)
const path = this.type + '/' + unprefixedpath
this.event.trigger('fileChanged', [path])
}).catch((error) => { }).catch((error) => {
if (cb) return cb(error) if (cb) return cb(error)
throw new Error(error) throw new Error(error)
@ -140,9 +148,7 @@ module.exports = class RemixDProvider {
delete this.filesContent[path] delete this.filesContent[path]
resolve(true) resolve(true)
this.init(() => { this.init()
this.event.trigger('fileRemoved', [path])
})
}).catch(error => { }).catch(error => {
if (error) console.log(error) if (error) console.log(error)
resolve(false) resolve(false)

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

Loading…
Cancel
Save