@@ -17,7 +17,7 @@ import domReady from '@wordpress/dom-ready'
1717import {
1818 Button , Flex , FlexItem , Spinner , CheckboxControl , Modal ,
1919} from '@wordpress/components'
20- import { loadPromise , models } from '@wordpress/api'
20+ import { models } from '@wordpress/api'
2121import { applyFilters } from '@wordpress/hooks'
2222
2323/**
@@ -31,7 +31,7 @@ import {
3131 defaultBreakpoints ,
3232} from 'stackable'
3333import classnames from 'classnames'
34- import { importBlocks } from '~stackable/util/admin'
34+ import { fetchSettings , importBlocks } from '~stackable/util/admin'
3535import { createRoot } from '~stackable/util/element'
3636import AdminSelectSetting from '~stackable/components/admin-select-setting'
3737import AdminToggleSetting from '~stackable/components/admin-toggle-setting'
@@ -309,11 +309,8 @@ const RestSettingsNotice = () => {
309309 const [ error , setError ] = useState ( null )
310310
311311 useEffect ( ( ) => {
312- loadPromise . then ( ( ) => {
313- const settings = new models . Settings ( )
314- settings . fetch ( ) . catch ( error => {
315- setError ( error )
316- } )
312+ fetchSettings ( ) . catch ( error => {
313+ setError ( error )
317314 } )
318315 } , [ ] )
319316
@@ -536,13 +533,10 @@ const Settings = () => {
536533 } , [ unsavedChanges , settings ] )
537534
538535 useEffect ( ( ) => {
539- loadPromise . then ( ( ) => {
540- const settings = new models . Settings ( )
541- settings . fetch ( ) . then ( response => {
542- setSettings ( response )
543- // Should only be set initially since we have to reload after setting for it to work with the backend
544- setHasV2Tab ( hasV2Compatibility ( response ) )
545- } )
536+ fetchSettings ( ) . then ( response => {
537+ setSettings ( response )
538+ // Should only be set initially since we have to reload after setting for it to work with the backend
539+ setHasV2Tab ( hasV2Compatibility ( response ) )
546540 } )
547541 } , [ ] )
548542
@@ -830,12 +824,12 @@ const Responsiveness = props => {
830824 label = { __ ( 'Tablet Breakpoint' , i18n ) }
831825 searchedSettings = { dynamicBreakpoints . children }
832826 type = "number"
833- value = { settings . stackable_dynamic_breakpoints . tablet || '' } // eslint-disable-line camelcase
827+ value = { settings . stackable_dynamic_breakpoints ? .tablet || '' } // eslint-disable-line camelcase
834828 onChange = { value => {
835829 handleSettingsChange ( {
836830 stackable_dynamic_breakpoints : { // eslint-disable-line camelcase
837831 tablet : value ,
838- mobile : settings . stackable_dynamic_breakpoints . mobile || '' , // eslint-disable-line camelcase
832+ mobile : settings . stackable_dynamic_breakpoints ? .mobile || '' , // eslint-disable-line camelcase
839833 } ,
840834 } )
841835 } }
@@ -845,11 +839,11 @@ const Responsiveness = props => {
845839 label = { __ ( 'Mobile Breakpoint' , i18n ) }
846840 searchedSettings = { dynamicBreakpoints . children }
847841 type = "number"
848- value = { settings . stackable_dynamic_breakpoints . mobile || '' } // eslint-disable-line camelcase
842+ value = { settings . stackable_dynamic_breakpoints ? .mobile || '' } // eslint-disable-line camelcase
849843 onChange = { value => {
850844 handleSettingsChange ( {
851845 stackable_dynamic_breakpoints : { // eslint-disable-line camelcase
852- tablet : settings . stackable_dynamic_breakpoints . tablet || '' , // eslint-disable-line camelcase
846+ tablet : settings . stackable_dynamic_breakpoints ? .tablet || '' , // eslint-disable-line camelcase
853847 mobile : value ,
854848 } ,
855849 } )
0 commit comments