@@ -6,6 +6,10 @@ import { DefaultSettings, settings } from '../../settings'
66import { tl } from '../../util/intl'
77import { ERROR } from '../../util/errors'
88const dialog = electron . dialog
9+ let updateSettingsUiActions = { }
10+ let forceUpdateSettingsUi = ( ) => {
11+ Object . values ( updateSettingsUiActions ) . forEach ( ( action ) => action ( ) )
12+ }
913const RenderTemplates = {
1014 checkbox ( { value, setValue, namespace, name, children, forceRerender } ) {
1115 return (
@@ -53,10 +57,12 @@ const RenderTemplates = {
5357 minWidth : 'unset' ,
5458 paddingLeft : '9px' ,
5559 } }
56- onClick = { ( ) =>
57- ( settings [ namespace ] [ name ] =
58- DefaultSettings [ namespace ] [ name ] . default )
59- }
60+ onClick = { ( ) => {
61+ settings . set (
62+ `${ namespace } .${ name } ` ,
63+ DefaultSettings [ namespace ] [ name ] . default
64+ )
65+ } }
6066 >
6167 < span
6268 className = "material-icons"
@@ -190,6 +196,8 @@ const SettingInput = ({ namespace, name, template }) => {
190196 const [ isValid , setIsValid ] = useState ( true )
191197 const [ isVisible , setIsVisible ] = useState ( true )
192198 const [ rerender , setRerender ] = useState ( 0 )
199+ updateSettingsUiActions [ `${ namespace } .${ name } ` ] = ( ) =>
200+ setRerender ( Math . random ( ) )
193201 useEffect ( ( ) => {
194202 // setValue(settings[namespace][name])
195203 return settings . watch ( namespace + '.' + name , ( v ) => {
@@ -354,10 +362,9 @@ const SettingInput = ({ namespace, name, template }) => {
354362 return null
355363 }
356364}
357- let forceUpdateSettingsUi = ( ) => { }
358365const Settings = ( ) => {
359366 const [ , forceRerender ] = useState ( 0 )
360- forceUpdateSettingsUi = ( ) => forceRerender ( Math . random ( ) )
367+ updateSettingsUiActions . main = ( ) => forceRerender ( Math . random ( ) )
361368 const ref = useRef ( )
362369 useEffect ( ( ) => {
363370 if ( ref . current ) {
0 commit comments