Skip to content

Commit 021e7e2

Browse files
authored
Merge pull request #837 from ethereum/remixd-currentFolderChanged
current folder changed
2 parents 34f6536 + b7997fb commit 021e7e2

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

apps/remix-ide/src/app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
391391
filePanel.gitHandle
392392
])
393393

394+
if (isElectron()) {
395+
appManager.activatePlugin('remixd')
396+
}
397+
394398
try {
395399
engine.register(await appManager.registeredPlugins())
396400
} catch (e) {
@@ -455,9 +459,5 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
455459
})
456460
}
457461

458-
if (isElectron()) {
459-
appManager.activatePlugin('remixd')
460-
}
461-
462462
if (params.embed) framingService.embed()
463463
}

apps/remix-ide/src/app/files/remixDProvider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ module.exports = class RemixDProvider {
4141
this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => {
4242
this.event.trigger('fileRemoved', [this.addPrefix(oldPath), this.addPrefix(newPath)])
4343
})
44+
45+
this._appManager.on('remixd', 'rootFolderChanged', () => {
46+
this.event.trigger('rootFolderChanged', [])
47+
})
4448
}
4549

4650
isConnected () {

libs/remix-ui/file-explorer/src/lib/file-explorer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
127127
if (state.fileManager) {
128128
filesProvider.event.register('fileExternallyChanged', fileExternallyChanged)
129129
filesProvider.event.register('fileRenamedError', fileRenamedError)
130+
filesProvider.event.register('rootFolderChanged', rootFolderChanged)
130131
}
131132
}, [state.fileManager])
132133

@@ -482,6 +483,15 @@ export const FileExplorer = (props: FileExplorerProps) => {
482483
}, null)
483484
}
484485

486+
// register to event of the file provider
487+
// files.event.register('rootFolderChanged', rootFolderChanged)
488+
const rootFolderChanged = async () => {
489+
const files = await fetchDirectoryContent(name)
490+
setState(prevState => {
491+
return { ...prevState, files }
492+
})
493+
}
494+
485495
const uploadFile = (target) => {
486496
// TODO The file explorer is merely a view on the current state of
487497
// the files module. Please ask the user here if they want to overwrite

libs/remixd/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
'use strict'
22
import { RemixdClient as sharedFolder } from './services/remixdClient'
3+
import { GitClient } from './services/gitClient'
34
import Websocket from './websocket'
45
import * as utils from './utils'
56

67
module.exports = {
78
Websocket,
89
utils,
910
services: {
10-
sharedFolder
11+
sharedFolder,
12+
GitClient
1113
}
1214
}

libs/remixd/src/services/remixdClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class RemixdClient extends PluginClient {
2020
sharedFolder (currentSharedFolder: string, readOnly: boolean): void {
2121
this.currentSharedFolder = currentSharedFolder
2222
this.readOnly = readOnly
23+
if (this.isLoaded) this.emit('rootFolderChanged')
2324
}
2425

2526
list (): Filelist {

0 commit comments

Comments
 (0)