diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index c9695e7bba..f197cba0ec 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -171,18 +171,18 @@ export class CodeParser extends Plugin { await this.call('fileDecorator', 'clearFileDecorators') setTimeout(async () => { await this.importService.setFileTree()} - , 2000) + , 3000) }) this.on('fileManager', 'fileAdded', async () => { setTimeout(async () => { await this.importService.setFileTree()} - , 2000) + , 3000) }) this.on('fileManager', 'fileRemoved', async () => { setTimeout(async () => { await this.importService.setFileTree()} - , 2000) + , 3000) }) this.on('fileManager', 'currentFileChanged', async () => { diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index 7ea3e4a292..3eb388673e 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -266,12 +266,18 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial await value.reloadFile(file) } + const updateFiles = async () => { + setTimeout(async () => { + setFiles(await getDirectory('/', plugin)) + }, 2000) + } + useEffect(() => { plugin.on('filePanel', 'setWorkspace', async (workspace) => { value.setSearchResults(null) value.clearUndo() value.setCurrentWorkspace(workspace.name) - setFiles(await getDirectory('/', plugin)) + await updateFiles() }) plugin.on('fileManager', 'fileSaved', async (file) => { await reloadStateForFile(file) @@ -280,15 +286,15 @@ export const SearchProvider = ({ children = [], reducer = SearchReducer, initial plugin.on('fileManager', 'rootFolderChanged', async (file) => { const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') if (workspace) value.setCurrentWorkspace(workspace.name) - setFiles(await getDirectory('/', plugin)) + await updateFiles() }) plugin.on('fs', 'workingDirChanged', async () => { - setFiles(await getDirectory('/', plugin)) + await updateFiles() }) plugin.on('fileManager', 'fileAdded', async (file) => { - setFiles(await getDirectory('/', plugin)) + await updateFiles() await reloadStateForFile(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') if (workspace && workspace.name) { value.setCurrentWorkspace(workspace.name) - setFiles(await getDirectory('/', plugin)) + await updateFiles() } } catch (e) { console.log(e) } } - setTimeout(async () => { - await fetchWorkspace() - }, 5000) - + + fetchWorkspace() + return () => { plugin.off('fileManager', 'fileChanged') plugin.off('filePanel', 'setWorkspace')