Skip to content

Migrate comment email subscription hooks to api-core/api-queries#109800

Draft
gabrielcaires wants to merge 1 commit intotrunkfrom
update/reader-migrate-comment-email-hooks
Draft

Migrate comment email subscription hooks to api-core/api-queries#109800
gabrielcaires wants to merge 1 commit intotrunkfrom
update/reader-migrate-comment-email-hooks

Conversation

@gabrielcaires
Copy link
Copy Markdown
Contributor

Part of READ-408

Proposed Changes

  • Extract pure mutator functions (updateSiteCommentEmailSubscription, deletePostCommentEmailSubscription) into @automattic/api-core under read-comment-email-subscriptions/.
  • Create mutationOptions() wrappers (siteEmailMeNewCommentsMutation, postCommentEmailUnsubscribeMutation) in @automattic/api-queries.
  • Update data-stores hooks (useSiteEmailMeNewCommentsMutation, usePostUnsubscribeMutation) to use the new api-core mutators instead of the custom callApi() helper, while preserving existing optimistic update logic.

Why are these changes being made?

This is part of an ongoing migration (Phase 3) to move Reader query/mutation logic from data-stores to the standardized api-core/api-queries pattern. Centralizing API calls in api-core with wpcom-fetcher and exposing mutationOptions from api-queries improves reusability, testability, and consistency across clients.

Testing Instructions

  • Verify "Email me new comments" toggle works on a site subscription row (Subscriptions > Sites).
  • Verify unsubscribing from a comment subscription works (Subscriptions > Comments).
  • Verify the Reader site subscription settings panel toggles comments email correctly.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

…D-408)

Extract pure mutator functions (updateSiteCommentEmailSubscription,
deletePostCommentEmailSubscription) into @automattic/api-core and create
mutationOptions wrappers in @automattic/api-queries. Update data-stores
hooks to use the new api-core mutators instead of the custom callApi helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@matticbot
Copy link
Copy Markdown
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/reader-migrate-comment-email-hooks on your sandbox.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants