diff --git a/apps/remix-ide/src/app/files/remixDProvider.js b/apps/remix-ide/src/app/files/remixDProvider.js index 8579b516be3..039f2651b3d 100644 --- a/apps/remix-ide/src/app/files/remixDProvider.js +++ b/apps/remix-ide/src/app/files/remixDProvider.js @@ -41,6 +41,10 @@ module.exports = class RemixDProvider { this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => { this.event.trigger('fileRemoved', [this.addPrefix(oldPath), this.addPrefix(newPath)]) }) + + this._appManager.on('remixd', 'rootFolderChanged', () => { + this.event.trigger('rootFolderChanged', []) + }) } isConnected () { diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 252b8d70d42..b1d1a46385e 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -127,6 +127,7 @@ export const FileExplorer = (props: FileExplorerProps) => { if (state.fileManager) { filesProvider.event.register('fileExternallyChanged', fileExternallyChanged) filesProvider.event.register('fileRenamedError', fileRenamedError) + filesProvider.event.register('rootFolderChanged', rootFolderChanged) } }, [state.fileManager]) @@ -482,6 +483,15 @@ export const FileExplorer = (props: FileExplorerProps) => { }, null) } + // register to event of the file provider + // files.event.register('rootFolderChanged', rootFolderChanged) + const rootFolderChanged = async () => { + const files = await fetchDirectoryContent(name) + setState(prevState => { + return { ...prevState, files } + }) + } + const uploadFile = (target) => { // TODO The file explorer is merely a view on the current state of // the files module. Please ask the user here if they want to overwrite diff --git a/libs/remixd/src/index.ts b/libs/remixd/src/index.ts index 8211aa8028d..04725c14f20 100644 --- a/libs/remixd/src/index.ts +++ b/libs/remixd/src/index.ts @@ -1,5 +1,6 @@ 'use strict' import { RemixdClient as sharedFolder } from './services/remixdClient' +import { GitClient } from './services/gitClient' import Websocket from './websocket' import * as utils from './utils' @@ -7,6 +8,7 @@ module.exports = { Websocket, utils, services: { - sharedFolder + sharedFolder, + GitClient } } diff --git a/libs/remixd/src/services/remixdClient.ts b/libs/remixd/src/services/remixdClient.ts index 4a48485c19a..584ca6a4816 100644 --- a/libs/remixd/src/services/remixdClient.ts +++ b/libs/remixd/src/services/remixdClient.ts @@ -20,6 +20,7 @@ export class RemixdClient extends PluginClient { sharedFolder (currentSharedFolder: string, readOnly: boolean): void { this.currentSharedFolder = currentSharedFolder this.readOnly = readOnly + this.emit('rootFolderChanged') } list (): Filelist {