Skip to content

Commit bfd2770

Browse files
committed
fix reload
1 parent 5de384a commit bfd2770

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
8787
useEffect(() => {
8888
if (workspaceName) {
8989
api.setAppParameter('configFilePath', defaultPath)
90+
// reset 'createFileOnce' in case of new workspace creation
91+
setState((prevState) => {
92+
return { ...prevState, createFileOnce: true }
93+
})
9094
if (state.useFileConfiguration) {
9195
api.fileExists(defaultPath).then((exists) => {
9296
if (!exists && state.useFileConfiguration) {
@@ -99,15 +103,6 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
99103
}
100104
}, [workspaceName])
101105

102-
useEffect(() => {
103-
if (state.useFileConfiguration) {
104-
api.fileExists(defaultPath).then((exists) => {
105-
if (!exists) createNewConfigFile()
106-
})
107-
setToggleExpander(true)
108-
}
109-
}, [state.useFileConfiguration])
110-
111106
useEffect(() => {
112107
if (online && state.onlyDownloaded){
113108
// @ts-ignore
@@ -246,7 +241,18 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
246241

247242
useEffect(() => {
248243
compileTabLogic.setUseFileConfiguration(state.useFileConfiguration)
249-
if (state.useFileConfiguration) compileTabLogic.setConfigFilePath(configFilePath)
244+
if (state.useFileConfiguration) {
245+
compileTabLogic.setConfigFilePath(configFilePath)
246+
if (state.createFileOnce && workspaceName) {
247+
api.fileExists(defaultPath).then((exists) => {
248+
if (!exists) createNewConfigFile()
249+
})
250+
setToggleExpander(true)
251+
setState((prevState) => {
252+
return { ...prevState, createFileOnce: false }
253+
})
254+
}
255+
}
250256
}, [state.useFileConfiguration])
251257

252258
useEffect(() => {
@@ -256,16 +262,6 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
256262
}, [configurationSettings])
257263

258264
const toggleConfigType = () => {
259-
if (state.useFileConfiguration)
260-
if (state.createFileOnce) {
261-
api.fileExists(defaultPath).then((exists) => {
262-
if (!exists) createNewConfigFile()
263-
})
264-
setState((prevState) => {
265-
return { ...prevState, createFileOnce: false }
266-
})
267-
}
268-
269265
setState((prevState) => {
270266
api.setAppParameter('useFileConfiguration', !state.useFileConfiguration)
271267
return { ...prevState, useFileConfiguration: !state.useFileConfiguration }

0 commit comments

Comments
 (0)