Skip to content

Commit

Permalink
Merge pull request #837 from ethereum/remixd-currentFolderChanged
Browse files Browse the repository at this point in the history
current folder changed
  • Loading branch information
ioedeveloper committed Feb 4, 2021
2 parents 34f6536 + b7997fb commit 021e7e2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 4 additions & 4 deletions apps/remix-ide/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
filePanel.gitHandle
])

if (isElectron()) {
appManager.activatePlugin('remixd')
}

try {
engine.register(await appManager.registeredPlugins())
} catch (e) {
Expand Down Expand Up @@ -455,9 +459,5 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
})
}

if (isElectron()) {
appManager.activatePlugin('remixd')
}

if (params.embed) framingService.embed()
}
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
if (this.isLoaded) this.emit('rootFolderChanged')
}

list (): Filelist {
Expand Down

0 comments on commit 021e7e2

Please sign in to comment.