-
Notifications
You must be signed in to change notification settings - Fork 843
Social: Refactor resharing and scheduling logic to clean it up #46322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 9 files. Only the first 5 are listed here.
4 files are newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
I don't care about code coverage for this PR
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the resharing and scheduling logic in the Publicize components by moving it from component-level state to centralized data store actions. The primary goal is to simplify the codebase by abstracting async sharing logic into the store, making it easier to track sharing status across the application. The PR also includes TypeScript conversions, component renaming, and UI adjustments to the NavigatorModal.
Key Changes
- Centralized resharing and scheduling logic in the data store with new actions (
shareCurrentPost,scheduleShares) and state flags (isSharingCurrentPost,isSchedulingShares) - Converted the share post hook and button component from JavaScript to TypeScript, with significant simplification of the hook's implementation
- Updated NavigatorModal z-index and height to ensure notifications remain visible above the modal
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
projects/js-packages/publicize-components/src/utils/share-post.ts |
New utility function to detect error responses from the API |
projects/js-packages/publicize-components/src/social-store/types.ts |
Added new type definitions for SharePost.isSharingCurrentPost and ScheduledShares.isScheduling state |
projects/js-packages/publicize-components/src/social-store/selectors/share-post.ts |
Added isSharingCurrentPost selector to check if post is being shared |
projects/js-packages/publicize-components/src/social-store/selectors/scheduled-shares.ts |
Added isSchedulingShares selector to check if shares are being scheduled |
projects/js-packages/publicize-components/src/social-store/reducer/share-post.ts |
Updated reducer to handle SET_IS_SHARING_CURRENT_POST action |
projects/js-packages/publicize-components/src/social-store/reducer/scheduled-shares.ts |
New reducer for scheduled shares state management |
projects/js-packages/publicize-components/src/social-store/reducer/index.ts |
Integrated the new scheduledShares reducer |
projects/js-packages/publicize-components/src/social-store/actions/share-post.ts |
Added shareCurrentPost action with complete share flow including post saving, API call, and status polling |
projects/js-packages/publicize-components/src/social-store/actions/scheduled-shares.ts |
Added scheduleShares action to handle multiple scheduled shares and moved success notice here |
projects/js-packages/publicize-components/src/social-store/actions/constants.ts |
Added SET_IS_SHARING_CURRENT_POST and SET_IS_SCHEDULING_SHARES action constants |
projects/js-packages/publicize-components/src/hooks/use-share-post/index.ts |
Converted to TypeScript and simplified to use store action instead of managing state locally |
projects/js-packages/publicize-components/src/hooks/use-share-post/index.js |
Deleted original JavaScript implementation (159 lines removed) |
projects/js-packages/publicize-components/src/hooks/use-share-post/Readme.md |
Deleted outdated documentation |
projects/js-packages/publicize-components/src/hooks/use-schedule-post/index.tsx |
Simplified to delegate to store action instead of managing scheduling logic directly |
projects/js-packages/publicize-components/src/hooks/use-is-resharing-possible/index.ts |
Updated to use isSharingCurrentPost selector instead of useSharePost hook |
projects/js-packages/publicize-components/src/components/unified-modal/social-post-preview/use-footer-actions.tsx |
Updated import path for renamed share post button |
projects/js-packages/publicize-components/src/components/social-post-modal/settings-section.tsx |
Updated import path for renamed share post button |
projects/js-packages/publicize-components/src/components/share-status/retry.tsx |
Updated to use new useSharePost hook API and removed unused imports |
projects/js-packages/publicize-components/src/components/share-post/index.jsx |
Deleted original share post button component (160 lines removed) |
projects/js-packages/publicize-components/src/components/share-post-button/index.tsx |
New TypeScript implementation of share post button using store actions |
projects/js-packages/publicize-components/src/components/schedule-button/index.tsx |
Simplified to use store selectors and removed local state management |
projects/js-packages/publicize-components/changelog/update-social-resharing |
Added changelog entry for the refactoring |
projects/js-packages/components/components/navigator-modal/styles.module.scss |
Updated z-index to 99999 and height to 48rem for better modal visibility |
projects/js-packages/components/changelog/update-social-resharing |
Added changelog entry for modal styling fixes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
projects/js-packages/publicize-components/src/components/share-post-button/index.tsx
Outdated
Show resolved
Hide resolved
projects/js-packages/publicize-components/src/social-store/actions/share-post.ts
Outdated
Show resolved
Hide resolved
projects/js-packages/components/components/navigator-modal/styles.module.scss
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
An alternative to #46321
Completes SOCIAL-269
We made resharing async a long time ago, which means that we don't immediately know the status of the sharing. For that we now have sharing status which is handled separately. But, that async logic update was not cleaned up for resharing logic and it made the whole process complicated to maintain. This PR aims to centralize the resharing and scheduling logic.
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
WP_Errorfromshare_post()andcreate_item()