diff --git a/apps/remix-ide/src/config.js b/apps/remix-ide/src/config.js index 7e0a900f37..f4ed5a8762 100644 --- a/apps/remix-ide/src/config.js +++ b/apps/remix-ide/src/config.js @@ -17,7 +17,6 @@ function Config (storage) { } catch (exception) { /* Do nothing. */ } - this.exists = function (key) { return this.items[key] !== undefined } @@ -36,6 +35,11 @@ function Config (storage) { } } + this.clear = function () { + this.items = {} + storage.remove(CONFIG_FILE) + } + this.getUnpersistedProperty = function (key) { return this.unpersistedItems[key] } diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 628c99b98e..6ddbfeaffd 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -25,13 +25,20 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const [themeName, ] = useState('') const [privateBeeAddress, setPrivateBeeAddress] = useState('') const [postageStampId, setPostageStampId] = useState('') + const [resetState, refresh] = useState(0) + + const initValue = () => { + const metadataConfig = props.config.get('settings/generate-contract-metadata') + if (metadataConfig === undefined || metadataConfig === null) generateContractMetadat(props.config, true, dispatch) + + const javascriptVM = props.config.get('settings/always-use-vm') + if (javascriptVM === null || javascriptVM === undefined) ethereumVM(props.config, true, dispatch) + } + useEffect(() => initValue(), [resetState, props.config]) + useEffect(() => initValue(), []) useEffect(() => { const token = props.config.get('settings/' + labels['gist'].key) - if (token === undefined) { - props.config.set('settings/generate-contract-metadata', true) - dispatch({ type: 'contractMetadata', payload: { name: 'contractMetadata', isChecked: true, textClass: textDark } }) - } if (token) { setTokenValue(prevState => { return { ...prevState, gist: token } @@ -58,12 +65,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { if (props.useMatomoAnalytics !== null) useMatomoAnalytics(props.config, props.useMatomoAnalytics, dispatch) }, [props.useMatomoAnalytics]) - useEffect(() => { - const javascriptVM = props.config.get('settings/always-use-vm') - - if ((javascriptVM === null) || (javascriptVM === undefined)) ethereumVM(props.config, true, dispatch) - }, [props.config]) - const onchangeGenerateContractMetadata = (event) => { generateContractMetadat(props.config, event.target.checked, dispatch) }