Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current folder changed #837

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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