Skip to content

Conversation

@manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Dec 16, 2025

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:

  • Move the resharing logic to the data store, removing the boilerplate code inside components. It makes it easier to check if resharing is in progress from anywhere. It also means that we no longer need to check if the post is being saved before resharing because that is now abstracted out into the store action itself.
  • Move some of the remaining scheduling logic to the store to make it a single source of truth to know whether scheduling is in progress.
  • Update the name and convert the share post button to TypeScript
  • Update NavigatorModal height and z-index to ensure that notices are always visible and above the modal.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Open the editor for an existing/published post
  • Try resharing the post for a few connections
  • Confirm that it works fine.
  • Confirm that both the "Share" and "Schedule" button is disabled for the entire duration of the process, including the save post process.
  • Schedule the post for a couple of connections
  • Confirm that it works fine and the schedules posts are displayed in the list
  • Confirm that both the buttons are disabled while the shares are being created.
  • Confirm that the messages (snackbars) are visible and above the modal.
  • Try for the error states by returning a WP_Error from share_post() and create_item()
return new WP_Error( 'some_random_error', 'Some random error', array( 'status' => 400 ) );

@manzoorwanijk manzoorwanijk self-assigned this Dec 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/social/resharing branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/social/resharing
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/social/resharing

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Dec 16, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 16, 2025

Code Coverage Summary

Coverage changed in 9 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/js-packages/publicize-components/src/social-store/actions/share-post.ts 1/30 (3.33%) 3.33% 26 💔
projects/js-packages/publicize-components/src/social-store/actions/scheduled-shares.ts 1/44 (2.27%) 2.27% 19 💔
projects/js-packages/publicize-components/src/social-store/reducer/share-post.ts 2/4 (50.00%) -16.67% 1 ❤️‍🩹
projects/js-packages/publicize-components/src/social-store/selectors/scheduled-shares.ts 4/15 (26.67%) -1.90% 1 ❤️‍🩹
projects/js-packages/publicize-components/src/social-store/selectors/share-post.ts 0/2 (0.00%) 0.00% 1 ❤️‍🩹

4 files are newly checked for coverage.

File Coverage
projects/js-packages/publicize-components/src/components/share-post-button/index.tsx 0/16 (0.00%) 💔
projects/js-packages/publicize-components/src/hooks/use-share-post/index.ts 0/7 (0.00%) 💔
projects/js-packages/publicize-components/src/utils/share-post.ts 0/5 (0.00%) 💔
projects/js-packages/publicize-components/src/social-store/reducer/scheduled-shares.ts 2/3 (66.67%) 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@manzoorwanijk manzoorwanijk changed the title Update/social/resharing Social: Refactor resharing and scheduling logic to clean it up Dec 17, 2025
@manzoorwanijk manzoorwanijk marked this pull request as ready for review December 17, 2025 05:28
@manzoorwanijk manzoorwanijk requested review from a team and Copilot December 17, 2025 05:28
@manzoorwanijk manzoorwanijk added [Type] Task and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Dec 17, 2025
@manzoorwanijk manzoorwanijk added the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Dec 17, 2025
@manzoorwanijk manzoorwanijk added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Dec 17, 2025
Copy link
Contributor

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants