fix setting default value

clear_storage
yann300 3 years ago
parent a681a3c375
commit e03954a59f
  1. 6
      apps/remix-ide/src/config.js
  2. 21
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx

@ -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]
}

@ -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)
}

Loading…
Cancel
Save