diff --git a/projects/js-packages/publicize-components/src/components/auto-conversion/toggle/index.tsx b/projects/js-packages/publicize-components/src/components/auto-conversion/toggle/index.tsx index f6130af40e3c6..ccea8a824cc5a 100644 --- a/projects/js-packages/publicize-components/src/components/auto-conversion/toggle/index.tsx +++ b/projects/js-packages/publicize-components/src/components/auto-conversion/toggle/index.tsx @@ -52,7 +52,7 @@ const AutoConversionToggle: React.FC< AutoConversionToggleProps > = ( { const toggleStatus = useCallback( () => { const newOption = { - image: ! isEnabled, + enabled: ! isEnabled, }; updateOptions( newOption ); }, [ isEnabled, updateOptions ] ); diff --git a/projects/js-packages/publicize-components/src/components/social-image-generator/template-picker/button/index.tsx b/projects/js-packages/publicize-components/src/components/social-image-generator/template-picker/button/index.tsx index 9e2a51c8023a1..be88f46ed6532 100644 --- a/projects/js-packages/publicize-components/src/components/social-image-generator/template-picker/button/index.tsx +++ b/projects/js-packages/publicize-components/src/components/social-image-generator/template-picker/button/index.tsx @@ -22,7 +22,7 @@ const TemplatePickerButton: React.FC = () => { useEffect( () => { if ( currentTemplate ) { - const newOption = { defaults: { template: currentTemplate } }; + const newOption = { template: currentTemplate }; updateOptions( newOption ); } }, [ currentTemplate, updateOptions ] ); diff --git a/projects/js-packages/publicize-components/src/social-store/actions/auto-conversion-settings.js b/projects/js-packages/publicize-components/src/social-store/actions/auto-conversion-settings.js index a404285cbe272..3b07290671e3d 100644 --- a/projects/js-packages/publicize-components/src/social-store/actions/auto-conversion-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/actions/auto-conversion-settings.js @@ -20,7 +20,7 @@ export function* updateAutoConversionSettings( settings ) { yield setAutoConversionSettings( settings ); yield updateAutoConversionSettingsControl( settings ); const updatedSettings = yield fetchAutoConversionSettings(); - yield setAutoConversionSettings( updatedSettings ); + yield setAutoConversionSettings( updatedSettings.jetpack_social_autoconvert_images ); return true; } catch ( e ) { const oldSettings = select( SOCIAL_STORE_ID ).getAutoConversionSettings(); @@ -41,7 +41,7 @@ export function* refreshAutoConversionSettings() { try { yield setUpdatingAutoConversionSettings(); const updatedSettings = yield fetchAutoConversionSettings(); - yield setAutoConversionSettings( updatedSettings ); + yield setAutoConversionSettings( updatedSettings.jetpack_social_autoconvert_images ); return true; } catch ( e ) { return false; diff --git a/projects/js-packages/publicize-components/src/social-store/actions/social-image-generator-settings.js b/projects/js-packages/publicize-components/src/social-store/actions/social-image-generator-settings.js index 121e15470cfe1..22d1f4917b733 100644 --- a/projects/js-packages/publicize-components/src/social-store/actions/social-image-generator-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/actions/social-image-generator-settings.js @@ -20,7 +20,9 @@ export function* updateSocialImageGeneratorSettings( settings ) { yield setSocialImageGeneratorSettings( settings ); yield updateSocialImageGeneratorSettingsControl( settings ); const updatedSettings = yield fetchSocialImageGeneratorSettings(); - yield setSocialImageGeneratorSettings( updatedSettings ); + yield setSocialImageGeneratorSettings( + updatedSettings.jetpack_social_image_generator_settings + ); return true; } catch ( e ) { const oldSettings = select( SOCIAL_STORE_ID ).getSocialImageGeneratorSettings(); @@ -69,7 +71,9 @@ export function* refreshSocialImageGeneratorSettings() { try { yield setUpdatingSocialImageGeneratorSettings(); const updatedSettings = yield fetchSocialImageGeneratorSettings(); - yield setSocialImageGeneratorSettings( updatedSettings ); + yield setSocialImageGeneratorSettings( + updatedSettings.jetpack_social_image_generator_settings + ); return true; } catch ( e ) { return false; diff --git a/projects/js-packages/publicize-components/src/social-store/controls.js b/projects/js-packages/publicize-components/src/social-store/controls.js index c504065dfc1e6..224f4220d078e 100644 --- a/projects/js-packages/publicize-components/src/social-store/controls.js +++ b/projects/js-packages/publicize-components/src/social-store/controls.js @@ -92,23 +92,31 @@ export default { } ); }, [ FETCH_SOCIAL_IMAGE_GENERATOR_SETTINGS ]: function () { - return apiFetch( { path: '/jetpack/v4/social-image-generator/settings' } ); + return apiFetch( { + path: '/wp/v2/settings?_fields=jetpack_social_image_generator_settings', + } ); }, [ UPDATE_SOCIAL_IMAGE_GENERATOR_SETTINGS ]: function ( action ) { return apiFetch( { - path: '/jetpack/v4/social-image-generator/settings', + path: '/wp/v2/settings', method: 'POST', - data: action.settings, + data: { + jetpack_social_image_generator_settings: action.settings, + }, } ); }, [ FETCH_AUTO_CONVERSION_SETTINGS ]: function () { - return apiFetch( { path: '/jetpack/v4/auto-conversion/settings' } ); + return apiFetch( { + path: '/wp/v2/settings?_fields=jetpack_social_autoconvert_images', + } ); }, [ UPDATE_AUTO_CONVERSION_SETTINGS ]: function ( action ) { return apiFetch( { - path: '/jetpack/v4/auto-conversion/settings', + path: '/wp/v2/settings', method: 'POST', - data: action.settings, + data: { + jetpack_social_autoconvert_images: action.settings, + }, } ); }, }; diff --git a/projects/js-packages/publicize-components/src/social-store/resolvers.js b/projects/js-packages/publicize-components/src/social-store/resolvers.js index 8defb29e8d7f4..fe566abe33544 100644 --- a/projects/js-packages/publicize-components/src/social-store/resolvers.js +++ b/projects/js-packages/publicize-components/src/social-store/resolvers.js @@ -38,7 +38,7 @@ export function* getSocialImageGeneratorSettings() { try { const settings = yield fetchSocialImageGeneratorSettings(); if ( settings ) { - return setSocialImageGeneratorSettings( settings ); + return setSocialImageGeneratorSettings( settings.jetpack_social_image_generator_settings ); } } catch ( e ) { // TODO: Add proper error handling here @@ -56,7 +56,7 @@ export function* getAutoConversionSettings() { try { const settings = yield fetchAutoConversionSettings(); if ( settings ) { - return setAutoConversionSettings( settings ); + return setAutoConversionSettings( settings.jetpack_social_autoconvert_images ); } } catch ( e ) { // TODO: Add proper error handling here diff --git a/projects/js-packages/publicize-components/src/social-store/selectors/auto-conversion-settings.js b/projects/js-packages/publicize-components/src/social-store/selectors/auto-conversion-settings.js index b3cd6729fb7cc..7d77e567023b7 100644 --- a/projects/js-packages/publicize-components/src/social-store/selectors/auto-conversion-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/selectors/auto-conversion-settings.js @@ -1,7 +1,7 @@ const autoConversionSettingsSelectors = { getAutoConversionSettings: state => state.autoConversionSettings, isAutoConversionAvailable: state => state.autoConversionSettings.available, - isAutoConversionEnabled: state => state.autoConversionSettings.image, + isAutoConversionEnabled: state => state.autoConversionSettings.enabled, isAutoConversionSettingsUpdating: state => state.autoConversionSettings.isUpdating, }; diff --git a/projects/js-packages/publicize-components/src/social-store/selectors/social-image-generator-settings.js b/projects/js-packages/publicize-components/src/social-store/selectors/social-image-generator-settings.js index e7dc3d44e4c52..25cf39b9dedd8 100644 --- a/projects/js-packages/publicize-components/src/social-store/selectors/social-image-generator-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/selectors/social-image-generator-settings.js @@ -3,8 +3,7 @@ const socialImageGeneratorSettingsSelectors = { isSocialImageGeneratorAvailable: state => state.socialImageGeneratorSettings.available, isSocialImageGeneratorEnabled: state => state.socialImageGeneratorSettings.enabled, isUpdatingSocialImageGeneratorSettings: state => state.socialImageGeneratorSettings.isUpdating, - getSocialImageGeneratorDefaultTemplate: state => - state.socialImageGeneratorSettings.defaultTemplate, + getSocialImageGeneratorDefaultTemplate: state => state.socialImageGeneratorSettings.template, }; export default socialImageGeneratorSettingsSelectors; diff --git a/projects/plugins/social/src/js/components/auto-conversion-toggle/index.tsx b/projects/plugins/social/src/js/components/auto-conversion-toggle/index.tsx index 42ca7c298d8ce..f2f9f177dea0a 100644 --- a/projects/plugins/social/src/js/components/auto-conversion-toggle/index.tsx +++ b/projects/plugins/social/src/js/components/auto-conversion-toggle/index.tsx @@ -38,7 +38,7 @@ const AutoConversionToggle: React.FC< AutoConversionToggleProps > = ( { const toggleStatus = useCallback( () => { const newOption = { - image: ! isEnabled, + enabled: ! isEnabled, }; updateOptions( newOption ); }, [ isEnabled, updateOptions ] );