From f2da8a0fb96b25df6ed6e993a726e2c85dcd8f68 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 10 Nov 2021 17:36:51 +0100 Subject: [PATCH] fix referesh --- apps/remix-ide/src/app/files/dgitProvider.js | 40 +++++++++++++++---- apps/remix-ide/src/app/files/fileManager.js | 2 +- .../src/app/ui/landing-page/landing-page.js | 5 ++- .../workspace/src/lib/actions/events.ts | 5 +++ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index faed358c87..84a9af0c63 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -90,7 +90,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig(), ...cmd }) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) } async rm (cmd) { @@ -98,7 +101,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig(), ...cmd }) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) } async checkout (cmd) { @@ -106,7 +112,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig(), ...cmd }) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) } async log (cmd) { @@ -131,7 +140,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig(), ...cmd }) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) return status } @@ -239,7 +251,10 @@ class DGitProvider extends Plugin { } const result = await git.clone(cmd) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) return result } @@ -272,7 +287,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig() } const result = await git.pull(cmd) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) return result } @@ -289,7 +307,10 @@ class DGitProvider extends Plugin { ...await this.getGitConfig() } const result = await git.fetch(cmd) - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) return result } @@ -467,7 +488,10 @@ class DGitProvider extends Plugin { } else { result = await this.importIPFSFiles(this.remixIPFS, cid, workspace) || await this.importIPFSFiles(this.ipfsconfig, cid, workspace) || await this.importIPFSFiles(this.globalIPFSConfig, cid, workspace) } - await this.call('fileManager', 'refresh') + const self = this + setTimeout(async () => { + await self.call('fileManager', 'refresh') + }, 1000) if (!result) throw new Error(`Cannot pull files from IPFS at ${cid}`) } diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 1771a1b0eb..bf2e8fa9f8 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -139,7 +139,7 @@ class FileManager extends Plugin { refresh () { const provider = this.fileProviderOf('/') // emit rootFolderChanged so that File Explorer reloads the file tree - provider.event.emit('rootFolderChanged', provider.workspace || '/') + this.emit('rootFolderChanged', provider.workspace || '/') } /** diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 9220a826bb..83a0700066 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -423,8 +423,9 @@ export class LandingPage extends ViewPlugin { } } const setDemoFile = async () => { - await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true) - await this.call('fileManager', 'setFile', 'tests/one/two/three/four/file.js', 'neihjiehjiheiheihiehiehiheiheihi') + // await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true) + // await this.call('fileManager', 'setFile', 'tests/one/two/three/four/file.js', 'neihjiehjiheiheihiehiehiheiheihi') + await this.call('fileManager', 'refresh') } const onAcceptDownloadn = async () => { diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index be34b71c3d..458a79f550 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -41,6 +41,10 @@ export const listenOnPluginEvents = (filePanelPlugin) => { plugin.on('remixd', 'rootFolderChanged', async (path: string) => { rootFolderChanged(path) }) + + plugin.on('fileManager', 'rootFolderChanged', async (path: string) => { + rootFolderChanged(path) + }) } export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch) => { @@ -182,5 +186,6 @@ const fileRenamed = async (oldPath: string) => { } const rootFolderChanged = async (path) => { + console.log('rootFolderChanged', path) await dispatch(rootFolderChangedSuccess(path)) }