-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Social: Refactor feature option storing (#34113)
* Add the new settings object + tests * Update initial states + previous usages * Update UI + store functions * changelog * Fix versions * Add control for fetching both options together * Social: Remove deprecated feature files (#34114) * Remove unneeded files * changelog * Social: Refresh store on Publicize module toggle via 1 call (#34142) * Remove previous refresh functionality * Add wrapper to refresh settings in class component on Jetpack Settings * Refresh on social admin page on module toggle change * Remove useEffect * Run useEffect only once on module update * Show toggles instantly on change + only refresh ones on page lifetime * Update ref logic * Rename structure * Fixup versions * Fix template issue, and make sure it's migrated * fix tests * Test fix * Fix auto-conversion migration logic + add test * Add auto-conversion sync option * changelog * Update versions * Fix versions
- Loading branch information
Showing
70 changed files
with
11,032 additions
and
11,611 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ects/js-packages/publicize-components/changelog/refactor-social-register-feature-settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: major | ||
Type: changed | ||
|
||
Social: Refactored storing of feature options to use core functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
.../js-packages/publicize-components/src/components/refresh-jetpack-social-settings/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useDispatch } from '@wordpress/data'; | ||
import { SOCIAL_STORE_ID } from '../../social-store'; | ||
|
||
/** | ||
* HOC that refreshes all of the Jetpack Social settings in the store, to be used in class components. | ||
* | ||
* @param {object} props - The component props. | ||
* @param {boolean} props.shouldRefresh - Whether or not to refresh the settings. | ||
* @param {object} props.children - The children to render. | ||
* @returns { object } The refreshJetpackSocialSettings function. | ||
*/ | ||
export default function RefreshJetpackSocialSettingsWrapper( { shouldRefresh, children } ) { | ||
const refreshOptions = useDispatch( SOCIAL_STORE_ID ).refreshJetpackSocialSettings; | ||
|
||
if ( shouldRefresh ) { | ||
refreshOptions(); | ||
} | ||
|
||
return children; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
projects/js-packages/publicize-components/src/social-store/actions/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ects/js-packages/publicize-components/src/social-store/actions/jetpack-social-settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { fetchJetpackSocialSettings } from '../controls'; | ||
import { | ||
setAutoConversionSettings, | ||
setUpdatingAutoConversionSettings, | ||
setUpdatingAutoConversionSettingsDone, | ||
} from './auto-conversion-settings'; | ||
import { | ||
setSocialImageGeneratorSettings, | ||
setUpdatingSocialImageGeneratorSettings, | ||
setUpdatingSocialImageGeneratorSettingsDone, | ||
} from './social-image-generator-settings'; | ||
|
||
/** | ||
* Yield actions to refresh all of the Jetpack Social registered settings. | ||
* | ||
* @yields {object} - an action object. | ||
* @returns {object} - an action object. | ||
*/ | ||
export function* refreshJetpackSocialSettings() { | ||
try { | ||
yield setUpdatingAutoConversionSettings(); | ||
yield setUpdatingSocialImageGeneratorSettings(); | ||
const updatedSettings = yield fetchJetpackSocialSettings(); | ||
yield setAutoConversionSettings( updatedSettings.jetpack_social_autoconvert_images ); | ||
yield setSocialImageGeneratorSettings( | ||
updatedSettings.jetpack_social_image_generator_settings | ||
); | ||
return true; | ||
} catch ( e ) { | ||
return false; | ||
} finally { | ||
yield setUpdatingAutoConversionSettingsDone(); | ||
yield setUpdatingSocialImageGeneratorSettingsDone(); | ||
} | ||
} | ||
|
||
export default { | ||
refreshJetpackSocialSettings, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/js-packages/publicize-components/src/social-store/selectors/auto-conversion-settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/packages/publicize/changelog/refactor-social-register-feature-settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: major | ||
Type: changed | ||
|
||
Social: Refactored storing of feature options to use core functions |
4 changes: 4 additions & 0 deletions
4
projects/packages/publicize/changelog/remove-social-deprecated-feature-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: removed | ||
|
||
Social: Removed deprecated files because of refactore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.