diff --git a/apps/remix-ide-e2e/src/tests/remixd.test.ts b/apps/remix-ide-e2e/src/tests/remixd.test.ts index 74b4059719..293bdb16c0 100644 --- a/apps/remix-ide-e2e/src/tests/remixd.test.ts +++ b/apps/remix-ide-e2e/src/tests/remixd.test.ts @@ -76,7 +76,6 @@ module.exports = { .addFile('test_import_node_modules_with_github_import.sol', sources[4]['test_import_node_modules_with_github_import.sol']) .clickLaunchIcon('solidity') .setSolidityCompilerVersion('soljson-v0.8.0+commit.c7dfd78e.js') // open-zeppelin moved to pragma ^0.8.0 - .pause(10000) .testContracts('test_import_node_modules_with_github_import.sol', sources[4]['test_import_node_modules_with_github_import.sol'], ['ERC20', 'test11']) }, 'Static Analysis run with remixd': function (browser) { diff --git a/apps/remix-ide/src/app/files/remixDProvider.js b/apps/remix-ide/src/app/files/remixDProvider.js index b52fd733bb..a36b6d8ec9 100644 --- a/apps/remix-ide/src/app/files/remixDProvider.js +++ b/apps/remix-ide/src/app/files/remixDProvider.js @@ -15,9 +15,9 @@ module.exports = class RemixDProvider extends FileProvider { _registerEvent () { var remixdEvents = ['connecting', 'connected', 'errored', 'closed'] - remixdEvents.forEach((value) => { - this._appManager.on('remixd', value, (event) => { - this.event.emit(value, event) + remixdEvents.forEach((event) => { + this._appManager.on('remixd', event, (value) => { + this.event.emit(event, value) }) }) @@ -44,6 +44,16 @@ module.exports = class RemixDProvider extends FileProvider { this._appManager.on('remixd', 'rootFolderChanged', (path) => { this.event.emit('rootFolderChanged', path) }) + + this._appManager.on('remixd', 'removed', (path) => { + this.event.emit('fileRemoved', path) + }) + + this._appManager.on('remixd', 'changed', (path) => { + this.get(path, (_error, content) => { + this.event.emit('fileExternallyChanged', path, content) + }) + }) } isConnected () { diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 40265c93e2..13e8f4c636 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -39,7 +39,7 @@ export const listenOnPluginEvents = (filePanelPlugin) => { }) } -export const listenOnProviderEvents = (provider) => async (reducerDispatch: React.Dispatch) => { +export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch) => { dispatch = reducerDispatch provider.event.on('fileAdded', (filePath: string) => { @@ -70,7 +70,7 @@ export const listenOnProviderEvents = (provider) => async (reducerDispatch: Reac }, 10) }) - provider.event.on('connected', async () => { + provider.event.on('connected', () => { setTimeout(() => { plugin.fileManager.setMode('localhost') dispatch(setMode('localhost')) @@ -79,33 +79,33 @@ export const listenOnProviderEvents = (provider) => async (reducerDispatch: Reac }, 10) }) - provider.event.on('loadingLocalhost', async () => { + provider.event.on('loadingLocalhost', () => { setTimeout(async () => { await switchToWorkspace(LOCALHOST) dispatch(loadLocalhostRequest()) }, 10) }) - provider.event.on('fileExternallyChanged', async (path: string, file: { content: string }) => { + provider.event.on('fileExternallyChanged', (path: string, content: string) => { setTimeout(() => { const config = plugin.registry.get('config').api const editor = plugin.registry.get('editor').api - if (config.get('currentFile') === path && editor.currentContent() !== file.content) { - if (provider.isReadOnly(path)) return editor.setText(file.content) + if (config.get('currentFile') === path && editor.currentContent() !== content) { + if (provider.isReadOnly(path)) return editor.setText(content) dispatch(displayNotification( path + ' changed', 'This file has been changed outside of Remix IDE.', 'Replace by the new content', 'Keep the content displayed in Remix', () => { - editor.setText(file.content) + editor.setText(content) } )) } }, 10) }) - provider.event.on('fileRenamedError', async () => { + provider.event.on('fileRenamedError', () => { setTimeout(() => dispatch(displayNotification('File Renamed Failed', '', 'Ok', 'Cancel')), 10) })