flattentree
bunsenstraat 11 months ago
parent bb419eb01f
commit 3b532e2383
  1. 6
      apps/remix-ide/src/app/plugins/parser/code-parser.tsx
  2. 23
      libs/remix-ui/search/src/lib/context/context.tsx

@ -171,18 +171,18 @@ export class CodeParser extends Plugin {
await this.call('fileDecorator', 'clearFileDecorators') await this.call('fileDecorator', 'clearFileDecorators')
setTimeout(async () => { setTimeout(async () => {
await this.importService.setFileTree()} await this.importService.setFileTree()}
, 2000) , 3000)
}) })
this.on('fileManager', 'fileAdded', async () => { this.on('fileManager', 'fileAdded', async () => {
setTimeout(async () => { setTimeout(async () => {
await this.importService.setFileTree()} await this.importService.setFileTree()}
, 2000) , 3000)
}) })
this.on('fileManager', 'fileRemoved', async () => { this.on('fileManager', 'fileRemoved', async () => {
setTimeout(async () => { setTimeout(async () => {
await this.importService.setFileTree()} await this.importService.setFileTree()}
, 2000) , 3000)
}) })
this.on('fileManager', 'currentFileChanged', async () => { this.on('fileManager', 'currentFileChanged', async () => {

@ -266,12 +266,18 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial
await value.reloadFile(file) await value.reloadFile(file)
} }
const updateFiles = async () => {
setTimeout(async () => {
setFiles(await getDirectory('/', plugin))
}, 2000)
}
useEffect(() => { useEffect(() => {
plugin.on('filePanel', 'setWorkspace', async (workspace) => { plugin.on('filePanel', 'setWorkspace', async (workspace) => {
value.setSearchResults(null) value.setSearchResults(null)
value.clearUndo() value.clearUndo()
value.setCurrentWorkspace(workspace.name) value.setCurrentWorkspace(workspace.name)
setFiles(await getDirectory('/', plugin)) await updateFiles()
}) })
plugin.on('fileManager', 'fileSaved', async (file) => { plugin.on('fileManager', 'fileSaved', async (file) => {
await reloadStateForFile(file) await reloadStateForFile(file)
@ -280,15 +286,15 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial
plugin.on('fileManager', 'rootFolderChanged', async (file) => { plugin.on('fileManager', 'rootFolderChanged', async (file) => {
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') const workspace = await plugin.call('filePanel', 'getCurrentWorkspace')
if (workspace) value.setCurrentWorkspace(workspace.name) if (workspace) value.setCurrentWorkspace(workspace.name)
setFiles(await getDirectory('/', plugin)) await updateFiles()
}) })
plugin.on('fs', 'workingDirChanged', async () => { plugin.on('fs', 'workingDirChanged', async () => {
setFiles(await getDirectory('/', plugin)) await updateFiles()
}) })
plugin.on('fileManager', 'fileAdded', async (file) => { plugin.on('fileManager', 'fileAdded', async (file) => {
setFiles(await getDirectory('/', plugin)) await updateFiles()
await reloadStateForFile(file) await reloadStateForFile(file)
}) })
plugin.on('fileManager', 'currentFileChanged', async (file) => { plugin.on('fileManager', 'currentFileChanged', async (file) => {
@ -300,16 +306,15 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') const workspace = await plugin.call('filePanel', 'getCurrentWorkspace')
if (workspace && workspace.name) { if (workspace && workspace.name) {
value.setCurrentWorkspace(workspace.name) value.setCurrentWorkspace(workspace.name)
setFiles(await getDirectory('/', plugin)) await updateFiles()
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
} }
setTimeout(async () => {
await fetchWorkspace() fetchWorkspace()
}, 5000)
return () => { return () => {
plugin.off('fileManager', 'fileChanged') plugin.off('fileManager', 'fileChanged')
plugin.off('filePanel', 'setWorkspace') plugin.off('filePanel', 'setWorkspace')

Loading…
Cancel
Save