fix autocompile

pull/4355/head
yann300 11 months ago
parent 21d9904ff0
commit 4eadb7ff0e
  1. 5
      libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
  2. 15
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

@ -1,5 +1,6 @@
import React from 'react' import React from 'react'
import { CompileTabLogic } from '../logic/compileTabLogic' import { CompileTabLogic } from '../logic/compileTabLogic'
export const setEditorMode = (mode: string) => { export const setEditorMode = (mode: string) => {
return { return {
type: 'SET_EDITOR_MODE', type: 'SET_EDITOR_MODE',
@ -28,7 +29,7 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch<any>) => {
export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispatch: React.Dispatch<any>) => { export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispatch: React.Dispatch<any>) => {
api.onSessionSwitched = () => { api.onSessionSwitched = () => {
dispatch(setEditorMode('sessionSwitched')) dispatch(setEditorMode('sessionSwitched_' + Date.now()))
} }
compileTabLogic.event.on('startingCompilation', () => { compileTabLogic.event.on('startingCompilation', () => {
@ -40,7 +41,7 @@ export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispat
}) })
api.onContentChanged = () => { api.onContentChanged = () => {
dispatch(setEditorMode('contentChanged')) dispatch(setEditorMode('contentChanged_' + Date.now()))
} }
compileTabLogic.compiler.event.register('loadingCompiler', () => { compileTabLogic.compiler.event.register('loadingCompiler', () => {
dispatch(setCompilerMode('loadingCompiler')) dispatch(setCompilerMode('loadingCompiler'))

@ -6,7 +6,7 @@ import {ConfigurationSettings} from '@remix-project/remix-lib'
import {checkSpecialChars, CustomTooltip, extractNameFromKey} from '@remix-ui/helper' import {checkSpecialChars, CustomTooltip, extractNameFromKey} from '@remix-ui/helper'
import {canUseWorker, urlFromVersion, pathToURL} from '@remix-project/remix-solidity' import {canUseWorker, urlFromVersion, pathToURL} from '@remix-project/remix-solidity'
import {compilerReducer, compilerInitialState} from './reducers/compiler' import {compilerReducer, compilerInitialState} from './reducers/compiler'
import {resetEditorMode, listenToEvents} from './actions/compiler' import {listenToEvents} from './actions/compiler'
import {getValidLanguage} from '@remix-project/remix-solidity' import {getValidLanguage} from '@remix-project/remix-solidity'
import {CopyToClipboard} from '@remix-ui/clipboard' import {CopyToClipboard} from '@remix-ui/clipboard'
import {configFileContent} from './compilerConfiguration' import {configFileContent} from './compilerConfiguration'
@ -231,16 +231,13 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
useEffect(() => { useEffect(() => {
if (compilerContainer.editor.mode) { if (compilerContainer.editor.mode) {
switch (compilerContainer.editor.mode) { if (compilerContainer.editor.mode.startsWith('sessionSwitched')) {
case 'sessionSwitched':
sessionSwitched() sessionSwitched()
resetEditorMode()(dispatch) return
break } else if (compilerContainer.editor.mode.startsWith('contentChanged')) {
case 'contentChanged':
contentChanged() contentChanged()
resetEditorMode()(dispatch) return
break }
}
} }
}, [compilerContainer.editor.mode]) }, [compilerContainer.editor.mode])

Loading…
Cancel
Save