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 4, 2021
1 parent b82378c commit 5248031
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
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
4 changes: 3 additions & 1 deletion libs/remixd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use strict'
import { RemixdClient as sharedFolder } from './services/remixdClient'
import { GitClient } from './services/gitClient'
import Websocket from './websocket'
import * as utils from './utils'

module.exports = {
Websocket,
utils,
services: {
sharedFolder
sharedFolder,
GitClient
}
}
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 5248031

Please sign in to comment.