Skip to content

Commit

Permalink
current folder changed
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Feb 3, 2021
1 parent b82378c commit 011bbeb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/remix-ide/src/app/files/remixDProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
10 changes: 10 additions & 0 deletions libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libs/remixd/src/services/remixdClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 011bbeb

Please sign in to comment.