@@ -17,16 +17,9 @@ import { ACTIONS } from '../../constants';
1717import SettingsContext from '../../context' ;
1818import Switch from './switch' ;
1919import Button from '../../../wizard/components/navigation/button' ;
20- import { update } from '../../utils' ;
20+ import { update , toggleAutoUpdate } from '../../utils' ;
2121
22- const Updater = ( {
23- title,
24- lastUpdated,
25- needsKey,
26- checked,
27- type,
28- onChange,
29- } ) => {
22+ const Updater = ( { title, lastUpdated, needsKey, checked, type } ) => {
3023 const [ id ] = useState ( _uniqueId ( 'updater-' ) ) ;
3124 const { state, dispatch } = useContext ( SettingsContext ) ;
3225 const isDisabled = needsKey && 'ok' !== state . apiStatus ;
@@ -54,6 +47,11 @@ const Updater = ( {
5447
5548 } ;
5649
50+ const handleAutoUpdateToggle = ( ) => {
51+ dispatch ( { type : ACTIONS . TOGGLE_UPDATES , payload : { type } } ) ;
52+ toggleAutoUpdate ( type ) ;
53+ } ;
54+
5755 return (
5856 < div className = "material-settings__updater" >
5957 < div className = "mdc-layout-grid" >
@@ -91,7 +89,11 @@ const Updater = ( {
9189
9290 < div className = "mdc-layout-grid__cell mdc-layout-grid__cell--span-2 mdc-layout-grid__cell--align-middle material-settings__cell--justify-end" >
9391 { ! isDisabled && (
94- < Switch checked = { checked } onChange = { onChange } id = { id } />
92+ < Switch
93+ checked = { checked }
94+ onChange = { handleAutoUpdateToggle }
95+ id = { id }
96+ />
9597 ) }
9698 </ div >
9799
0 commit comments