emit event only if needed

pull/2404/head
yann300 3 years ago
parent 264382b153
commit b465d7daf7
  1. 6
      apps/remix-ide/src/app/files/fileProvider.js
  2. 10
      libs/remix-ui/workspace/src/lib/actions/events.ts

@ -135,16 +135,12 @@ class FileProvider {
if (!await window.remixFileSystem.exists(currentCheck)) {
try {
await window.remixFileSystem.mkdir(currentCheck)
this.event.emit('folderAdded', this._normalizePath(currentCheck))
} catch (error) {
console.log(error)
}
}
}
currentCheck = ''
for (const value of paths) {
currentCheck = currentCheck + '/' + value
this.event.emit('folderAdded', this._normalizePath(currentCheck))
}
if (cb) cb()
}

@ -49,6 +49,16 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
plugin.on('fileManager', 'fileClosed', async (file: string) => {
dispatch(removeFocus(file))
})
plugin.on('fileManager', 'currentFileChanged', async (file: string) => {
const paths = file.split('/')
if (paths.length && paths[0] === '') paths.shift()
let currentCheck = ''
for (const value of paths) {
currentCheck = currentCheck + '/' + value
await folderAdded(currentCheck)
}
})
}
export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch<any>) => {

Loading…
Cancel
Save