@automattic/data-stores 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/cjs/agents-manager/actions.js +116 -0
- package/dist/cjs/agents-manager/actions.js.map +1 -0
- package/dist/cjs/agents-manager/constants.js +5 -0
- package/dist/cjs/agents-manager/constants.js.map +1 -0
- package/dist/cjs/agents-manager/index.js +37 -0
- package/dist/cjs/agents-manager/index.js.map +1 -0
- package/dist/cjs/agents-manager/persist-state.js +58 -0
- package/dist/cjs/agents-manager/persist-state.js.map +1 -0
- package/dist/cjs/agents-manager/reducer.js +87 -0
- package/dist/cjs/agents-manager/reducer.js.map +1 -0
- package/dist/cjs/agents-manager/resolvers.js +60 -0
- package/dist/cjs/agents-manager/resolvers.js.map +1 -0
- package/dist/cjs/agents-manager/selectors.js +44 -0
- package/dist/cjs/agents-manager/selectors.js.map +1 -0
- package/dist/cjs/agents-manager/types.js +3 -0
- package/dist/cjs/agents-manager/types.js.map +1 -0
- package/dist/cjs/contextual-help/admin-sections.js +1 -1
- package/dist/cjs/contextual-help/admin-sections.js.map +1 -1
- package/dist/cjs/help-center/actions.js +67 -63
- package/dist/cjs/help-center/actions.js.map +1 -1
- package/dist/cjs/help-center/constants.js +2 -1
- package/dist/cjs/help-center/constants.js.map +1 -1
- package/dist/cjs/help-center/index.js +14 -27
- package/dist/cjs/help-center/index.js.map +1 -1
- package/dist/cjs/help-center/reducer.js +17 -2
- package/dist/cjs/help-center/reducer.js.map +1 -1
- package/dist/cjs/help-center/resolvers.js +45 -25
- package/dist/cjs/help-center/resolvers.js.map +1 -1
- package/dist/cjs/help-center/selectors.js +7 -1
- package/dist/cjs/help-center/selectors.js.map +1 -1
- package/dist/cjs/help-center/utils.js +136 -0
- package/dist/cjs/help-center/utils.js.map +1 -0
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mutations/use-domains-bulk-actions-mutation.js +3 -3
- package/dist/cjs/mutations/use-domains-bulk-actions-mutation.js.map +1 -1
- package/dist/cjs/newsletter-categories/index.js +2 -2
- package/dist/cjs/newsletter-categories/index.js.map +1 -1
- package/dist/cjs/onboard/actions.js +6 -1
- package/dist/cjs/onboard/actions.js.map +1 -1
- package/dist/cjs/onboard/reducer.js +12 -1
- package/dist/cjs/onboard/reducer.js.map +1 -1
- package/dist/cjs/onboard/selectors.js +3 -1
- package/dist/cjs/onboard/selectors.js.map +1 -1
- package/dist/cjs/plans/constants.js +3 -1
- package/dist/cjs/plans/constants.js.map +1 -1
- package/dist/cjs/plans/hooks/use-pricing-meta-for-grid-plans.js +35 -18
- package/dist/cjs/plans/hooks/use-pricing-meta-for-grid-plans.js.map +1 -1
- package/dist/cjs/plans/index.js +2 -1
- package/dist/cjs/plans/index.js.map +1 -1
- package/dist/cjs/plans/queries/use-plans.js +2 -2
- package/dist/cjs/plans/queries/use-plans.js.map +1 -1
- package/dist/cjs/plans/queries/use-site-plans.js +2 -2
- package/dist/cjs/plans/queries/use-site-plans.js.map +1 -1
- package/dist/cjs/plans/resolvers.js +0 -1
- package/dist/cjs/plans/resolvers.js.map +1 -1
- package/dist/cjs/plans/selectors.js.map +1 -1
- package/dist/cjs/products-list/queries/use-products.js +2 -2
- package/dist/cjs/products-list/queries/use-products.js.map +1 -1
- package/dist/cjs/products-list/resolvers.js +2 -2
- package/dist/cjs/products-list/resolvers.js.map +1 -1
- package/dist/cjs/purchases/lib/assembler.js +9 -4
- package/dist/cjs/purchases/lib/assembler.js.map +1 -1
- package/dist/cjs/purchases/queries/use-get-jetpack-transferred-license-purchases.js +2 -2
- package/dist/cjs/purchases/queries/use-get-jetpack-transferred-license-purchases.js.map +1 -1
- package/dist/cjs/purchases/queries/use-site-purchases.js +3 -3
- package/dist/cjs/purchases/queries/use-site-purchases.js.map +1 -1
- package/dist/cjs/queries/use-all-domains-query.js +2 -2
- package/dist/cjs/queries/use-all-domains-query.js.map +1 -1
- package/dist/cjs/queries/use-bulk-domain-update-status-query.js +3 -57
- package/dist/cjs/queries/use-bulk-domain-update-status-query.js.map +1 -1
- package/dist/cjs/queries/use-happiness-engineers-query.js +2 -2
- package/dist/cjs/queries/use-happiness-engineers-query.js.map +1 -1
- package/dist/cjs/queries/use-launchpad.js +5 -5
- package/dist/cjs/queries/use-launchpad.js.map +1 -1
- package/dist/cjs/queries/use-site-domains-query.js +2 -2
- package/dist/cjs/queries/use-site-domains-query.js.map +1 -1
- package/dist/cjs/queries/use-site-intent.js +2 -2
- package/dist/cjs/queries/use-site-intent.js.map +1 -1
- package/dist/cjs/queries/use-site-query.js +2 -2
- package/dist/cjs/queries/use-site-query.js.map +1 -1
- package/dist/cjs/reader/contexts/index.js +1 -4
- package/dist/cjs/reader/contexts/index.js.map +1 -1
- package/dist/cjs/reader/helpers/index.js +4 -3
- package/dist/cjs/reader/helpers/index.js.map +1 -1
- package/dist/cjs/reader/helpers/optimistic-update.js +2 -1
- package/dist/cjs/reader/helpers/optimistic-update.js.map +1 -1
- package/dist/cjs/reader/index.js +2 -8
- package/dist/cjs/reader/index.js.map +1 -1
- package/dist/cjs/reader/mutations/use-pending-site-confirm-mutation.js +2 -2
- package/dist/cjs/reader/mutations/use-pending-site-confirm-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-delivery-frequency-mutation.js +26 -20
- package/dist/cjs/reader/mutations/use-site-delivery-frequency-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-email-me-new-comments-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-email-me-new-comments-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-email-me-new-posts-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-email-me-new-posts-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-notify-me-of-new-posts-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-notify-me-of-new-posts-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-subscribe-mutation.js +10 -4
- package/dist/cjs/reader/mutations/use-site-subscribe-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-unsubscribe-mutation.js +11 -4
- package/dist/cjs/reader/mutations/use-site-unsubscribe-mutation.js.map +1 -1
- package/dist/cjs/reader/queries/index.js +2 -8
- package/dist/cjs/reader/queries/index.js.map +1 -1
- package/dist/cjs/reader/queries/use-site-subscriptions-query.js +27 -26
- package/dist/cjs/reader/queries/use-site-subscriptions-query.js.map +1 -1
- package/dist/cjs/site/queries/use-site-features.js +2 -2
- package/dist/cjs/site/queries/use-site-features.js.map +1 -1
- package/dist/cjs/site/queries/use-site-media-storage.js +2 -2
- package/dist/cjs/site/queries/use-site-media-storage.js.map +1 -1
- package/dist/cjs/site/queries/use-site-user-query.js +2 -2
- package/dist/cjs/site/queries/use-site-user-query.js.map +1 -1
- package/dist/cjs/site/queries/use-site.js +2 -2
- package/dist/cjs/site/queries/use-site.js.map +1 -1
- package/dist/cjs/site/resolvers.js +5 -5
- package/dist/cjs/site/resolvers.js.map +1 -1
- package/dist/cjs/site/selectors.js +5 -3
- package/dist/cjs/site/selectors.js.map +1 -1
- package/dist/cjs/site/types.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-content-summary-query.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-content-summary-query.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-mutation.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-mutation.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-status-query.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-status-query.js.map +1 -1
- package/dist/cjs/starter-designs-queries/use-starter-design-by-slug.js +2 -2
- package/dist/cjs/starter-designs-queries/use-starter-design-by-slug.js.map +1 -1
- package/dist/cjs/starter-designs-queries/use-starter-designs-query.js +2 -2
- package/dist/cjs/starter-designs-queries/use-starter-designs-query.js.map +1 -1
- package/dist/cjs/subscriber/actions.js +5 -5
- package/dist/cjs/subscriber/actions.js.map +1 -1
- package/dist/cjs/templates/use-template.js +2 -2
- package/dist/cjs/templates/use-template.js.map +1 -1
- package/dist/cjs/users/use-send-invites.js +2 -2
- package/dist/cjs/users/use-send-invites.js.map +1 -1
- package/dist/cjs/utils.js +26 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/wpcom-request-controls/index.js +3 -2
- package/dist/cjs/wpcom-request-controls/index.js.map +1 -1
- package/dist/cjs/wpcom-request.js +24 -0
- package/dist/cjs/wpcom-request.js.map +1 -0
- package/dist/esm/agents-manager/actions.js +104 -0
- package/dist/esm/agents-manager/actions.js.map +1 -0
- package/dist/esm/agents-manager/constants.js +2 -0
- package/dist/esm/agents-manager/constants.js.map +1 -0
- package/dist/esm/agents-manager/index.js +31 -0
- package/dist/esm/agents-manager/index.js.map +1 -0
- package/dist/esm/agents-manager/persist-state.js +54 -0
- package/dist/esm/agents-manager/persist-state.js.map +1 -0
- package/dist/esm/agents-manager/reducer.js +82 -0
- package/dist/esm/agents-manager/reducer.js.map +1 -0
- package/dist/esm/agents-manager/resolvers.js +57 -0
- package/dist/esm/agents-manager/resolvers.js.map +1 -0
- package/dist/esm/agents-manager/selectors.js +31 -0
- package/dist/esm/agents-manager/selectors.js.map +1 -0
- package/dist/esm/agents-manager/types.js +2 -0
- package/dist/esm/agents-manager/types.js.map +1 -0
- package/dist/esm/contextual-help/admin-sections.js +1 -1
- package/dist/esm/contextual-help/admin-sections.js.map +1 -1
- package/dist/esm/help-center/actions.js +63 -61
- package/dist/esm/help-center/actions.js.map +1 -1
- package/dist/esm/help-center/constants.js +1 -0
- package/dist/esm/help-center/constants.js.map +1 -1
- package/dist/esm/help-center/index.js +11 -23
- package/dist/esm/help-center/index.js.map +1 -1
- package/dist/esm/help-center/reducer.js +17 -2
- package/dist/esm/help-center/reducer.js.map +1 -1
- package/dist/esm/help-center/resolvers.js +43 -25
- package/dist/esm/help-center/resolvers.js.map +1 -1
- package/dist/esm/help-center/selectors.js +3 -0
- package/dist/esm/help-center/selectors.js.map +1 -1
- package/dist/esm/help-center/utils.js +127 -0
- package/dist/esm/help-center/utils.js.map +1 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mutations/use-domains-bulk-actions-mutation.js +1 -1
- package/dist/esm/mutations/use-domains-bulk-actions-mutation.js.map +1 -1
- package/dist/esm/newsletter-categories/index.js +1 -1
- package/dist/esm/newsletter-categories/index.js.map +1 -1
- package/dist/esm/onboard/actions.js +4 -0
- package/dist/esm/onboard/actions.js.map +1 -1
- package/dist/esm/onboard/reducer.js +10 -0
- package/dist/esm/onboard/reducer.js.map +1 -1
- package/dist/esm/onboard/selectors.js +1 -0
- package/dist/esm/onboard/selectors.js.map +1 -1
- package/dist/esm/plans/constants.js +2 -0
- package/dist/esm/plans/constants.js.map +1 -1
- package/dist/esm/plans/hooks/use-pricing-meta-for-grid-plans.js +35 -18
- package/dist/esm/plans/hooks/use-pricing-meta-for-grid-plans.js.map +1 -1
- package/dist/esm/plans/index.js +1 -1
- package/dist/esm/plans/index.js.map +1 -1
- package/dist/esm/plans/queries/use-plans.js +1 -1
- package/dist/esm/plans/queries/use-site-plans.js +1 -1
- package/dist/esm/plans/resolvers.js +0 -1
- package/dist/esm/plans/resolvers.js.map +1 -1
- package/dist/esm/plans/selectors.js.map +1 -1
- package/dist/esm/products-list/queries/use-products.js +1 -1
- package/dist/esm/products-list/queries/use-products.js.map +1 -1
- package/dist/esm/products-list/resolvers.js +1 -1
- package/dist/esm/products-list/resolvers.js.map +1 -1
- package/dist/esm/purchases/lib/assembler.js +9 -4
- package/dist/esm/purchases/lib/assembler.js.map +1 -1
- package/dist/esm/purchases/queries/use-get-jetpack-transferred-license-purchases.js +1 -1
- package/dist/esm/purchases/queries/use-site-purchases.js +2 -2
- package/dist/esm/queries/use-all-domains-query.js +1 -1
- package/dist/esm/queries/use-all-domains-query.js.map +1 -1
- package/dist/esm/queries/use-bulk-domain-update-status-query.js +3 -56
- package/dist/esm/queries/use-bulk-domain-update-status-query.js.map +1 -1
- package/dist/esm/queries/use-happiness-engineers-query.js +1 -1
- package/dist/esm/queries/use-happiness-engineers-query.js.map +1 -1
- package/dist/esm/queries/use-launchpad.js +1 -1
- package/dist/esm/queries/use-launchpad.js.map +1 -1
- package/dist/esm/queries/use-site-domains-query.js +1 -1
- package/dist/esm/queries/use-site-domains-query.js.map +1 -1
- package/dist/esm/queries/use-site-intent.js +1 -1
- package/dist/esm/queries/use-site-intent.js.map +1 -1
- package/dist/esm/queries/use-site-query.js +1 -1
- package/dist/esm/queries/use-site-query.js.map +1 -1
- package/dist/esm/reader/contexts/index.js +0 -1
- package/dist/esm/reader/contexts/index.js.map +1 -1
- package/dist/esm/reader/helpers/index.js +3 -2
- package/dist/esm/reader/helpers/index.js.map +1 -1
- package/dist/esm/reader/helpers/optimistic-update.js +2 -1
- package/dist/esm/reader/helpers/optimistic-update.js.map +1 -1
- package/dist/esm/reader/index.js +2 -3
- package/dist/esm/reader/index.js.map +1 -1
- package/dist/esm/reader/mutations/use-pending-site-confirm-mutation.js +2 -2
- package/dist/esm/reader/mutations/use-pending-site-confirm-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-delivery-frequency-mutation.js +27 -21
- package/dist/esm/reader/mutations/use-site-delivery-frequency-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-email-me-new-comments-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-email-me-new-comments-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-email-me-new-posts-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-email-me-new-posts-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-notify-me-of-new-posts-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-notify-me-of-new-posts-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-subscribe-mutation.js +10 -4
- package/dist/esm/reader/mutations/use-site-subscribe-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-unsubscribe-mutation.js +11 -4
- package/dist/esm/reader/mutations/use-site-unsubscribe-mutation.js.map +1 -1
- package/dist/esm/reader/queries/index.js +1 -4
- package/dist/esm/reader/queries/index.js.map +1 -1
- package/dist/esm/reader/queries/use-site-subscriptions-query.js +28 -27
- package/dist/esm/reader/queries/use-site-subscriptions-query.js.map +1 -1
- package/dist/esm/site/queries/use-site-features.js +1 -1
- package/dist/esm/site/queries/use-site-media-storage.js +1 -1
- package/dist/esm/site/queries/use-site-user-query.js +1 -1
- package/dist/esm/site/queries/use-site-user-query.js.map +1 -1
- package/dist/esm/site/queries/use-site.js +1 -1
- package/dist/esm/site/resolvers.js +1 -1
- package/dist/esm/site/resolvers.js.map +1 -1
- package/dist/esm/site/selectors.js +5 -3
- package/dist/esm/site/selectors.js.map +1 -1
- package/dist/esm/site/types.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-content-summary-query.js +1 -1
- package/dist/esm/site-reset/use-site-reset-content-summary-query.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-mutation.js +1 -1
- package/dist/esm/site-reset/use-site-reset-mutation.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-status-query.js +1 -1
- package/dist/esm/site-reset/use-site-reset-status-query.js.map +1 -1
- package/dist/esm/starter-designs-queries/use-starter-design-by-slug.js +1 -1
- package/dist/esm/starter-designs-queries/use-starter-design-by-slug.js.map +1 -1
- package/dist/esm/starter-designs-queries/use-starter-designs-query.js +1 -1
- package/dist/esm/starter-designs-queries/use-starter-designs-query.js.map +1 -1
- package/dist/esm/subscriber/actions.js +1 -1
- package/dist/esm/subscriber/actions.js.map +1 -1
- package/dist/esm/templates/use-template.js +1 -1
- package/dist/esm/templates/use-template.js.map +1 -1
- package/dist/esm/users/use-send-invites.js +1 -1
- package/dist/esm/users/use-send-invites.js.map +1 -1
- package/dist/esm/utils.js +21 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/wpcom-request-controls/index.js +2 -1
- package/dist/esm/wpcom-request-controls/index.js.map +1 -1
- package/dist/esm/wpcom-request.js +18 -0
- package/dist/esm/wpcom-request.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/add-ons/types.d.ts +1 -0
- package/dist/types/add-ons/types.d.ts.map +1 -1
- package/dist/types/agents-manager/actions.d.ts +77 -0
- package/dist/types/agents-manager/actions.d.ts.map +1 -0
- package/dist/types/agents-manager/constants.d.ts +2 -0
- package/dist/types/agents-manager/constants.d.ts.map +1 -0
- package/dist/types/agents-manager/index.d.ts +6 -0
- package/dist/types/agents-manager/index.d.ts.map +1 -0
- package/dist/types/agents-manager/persist-state.d.ts +6 -0
- package/dist/types/agents-manager/persist-state.d.ts.map +1 -0
- package/dist/types/agents-manager/reducer.d.ts +29 -0
- package/dist/types/agents-manager/reducer.d.ts.map +1 -0
- package/dist/types/agents-manager/resolvers.d.ts +54 -0
- package/dist/types/agents-manager/resolvers.d.ts.map +1 -0
- package/dist/types/agents-manager/selectors.d.ts +22 -0
- package/dist/types/agents-manager/selectors.d.ts.map +1 -0
- package/dist/types/agents-manager/types.d.ts +20 -0
- package/dist/types/agents-manager/types.d.ts.map +1 -0
- package/dist/types/contextual-help/admin-sections.d.ts +330 -6
- package/dist/types/contextual-help/admin-sections.d.ts.map +1 -1
- package/dist/types/contextual-help/contextual-help.d.ts +410 -30
- package/dist/types/contextual-help/contextual-help.d.ts.map +1 -1
- package/dist/types/help-center/actions.d.ts +235 -30
- package/dist/types/help-center/actions.d.ts.map +1 -1
- package/dist/types/help-center/constants.d.ts +1 -0
- package/dist/types/help-center/constants.d.ts.map +1 -1
- package/dist/types/help-center/index.d.ts +1 -2
- package/dist/types/help-center/index.d.ts.map +1 -1
- package/dist/types/help-center/reducer.d.ts +13 -2
- package/dist/types/help-center/reducer.d.ts.map +1 -1
- package/dist/types/help-center/resolvers.d.ts +4 -31
- package/dist/types/help-center/resolvers.d.ts.map +1 -1
- package/dist/types/help-center/selectors.d.ts +11 -1
- package/dist/types/help-center/selectors.d.ts.map +1 -1
- package/dist/types/help-center/types.d.ts +20 -12
- package/dist/types/help-center/types.d.ts.map +1 -1
- package/dist/types/help-center/utils.d.ts +13 -0
- package/dist/types/help-center/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -298
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/onboard/actions.d.ts +19 -3
- package/dist/types/onboard/actions.d.ts.map +1 -1
- package/dist/types/onboard/reducer.d.ts +4 -1
- package/dist/types/onboard/reducer.d.ts.map +1 -1
- package/dist/types/onboard/selectors.d.ts +8 -6
- package/dist/types/onboard/selectors.d.ts.map +1 -1
- package/dist/types/plans/constants.d.ts +3 -2
- package/dist/types/plans/constants.d.ts.map +1 -1
- package/dist/types/plans/hooks/use-pricing-meta-for-grid-plans.d.ts +6 -1
- package/dist/types/plans/hooks/use-pricing-meta-for-grid-plans.d.ts.map +1 -1
- package/dist/types/plans/index.d.ts +1 -1
- package/dist/types/plans/index.d.ts.map +1 -1
- package/dist/types/plans/resolvers.d.ts.map +1 -1
- package/dist/types/plans/types.d.ts +6 -0
- package/dist/types/plans/types.d.ts.map +1 -1
- package/dist/types/products-list/index.d.ts +1 -1
- package/dist/types/products-list/index.d.ts.map +1 -1
- package/dist/types/products-list/queries/use-products.d.ts.map +1 -1
- package/dist/types/purchases/lib/assembler.d.ts.map +1 -1
- package/dist/types/purchases/types.d.ts +37 -0
- package/dist/types/purchases/types.d.ts.map +1 -1
- package/dist/types/queries/use-all-domains-query.d.ts +2 -2
- package/dist/types/queries/use-all-domains-query.d.ts.map +1 -1
- package/dist/types/queries/use-bulk-domain-update-status-query.d.ts +5 -48
- package/dist/types/queries/use-bulk-domain-update-status-query.d.ts.map +1 -1
- package/dist/types/queries/use-site-intent.d.ts.map +1 -1
- package/dist/types/reader/contexts/index.d.ts +0 -1
- package/dist/types/reader/contexts/index.d.ts.map +1 -1
- package/dist/types/reader/helpers/index.d.ts.map +1 -1
- package/dist/types/reader/helpers/optimistic-update.d.ts.map +1 -1
- package/dist/types/reader/index.d.ts +13 -299
- package/dist/types/reader/index.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-delivery-frequency-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-delivery-frequency-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-email-me-new-comments-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-email-me-new-comments-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-email-me-new-posts-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-email-me-new-posts-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-notify-me-of-new-posts-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-notify-me-of-new-posts-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-subscribe-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-subscribe-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-unsubscribe-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-unsubscribe-mutation.d.ts.map +1 -1
- package/dist/types/reader/queries/index.d.ts +1 -5
- package/dist/types/reader/queries/index.d.ts.map +1 -1
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts +6 -225
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts.map +1 -1
- package/dist/types/reader/types/index.d.ts +32 -44
- package/dist/types/reader/types/index.d.ts.map +1 -1
- package/dist/types/shared-types.d.ts +11 -0
- package/dist/types/shared-types.d.ts.map +1 -1
- package/dist/types/site/actions.d.ts +1 -1
- package/dist/types/site/actions.d.ts.map +1 -1
- package/dist/types/site/queries/use-site-user-query.d.ts.map +1 -1
- package/dist/types/site/selectors.d.ts.map +1 -1
- package/dist/types/site/types.d.ts +4 -1
- package/dist/types/site/types.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/types.d.ts +1 -1
- package/dist/types/starter-designs-queries/types.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/use-starter-design-by-slug.d.ts +1 -1
- package/dist/types/starter-designs-queries/use-starter-design-by-slug.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/use-starter-designs-query.d.ts +1 -1
- package/dist/types/starter-designs-queries/use-starter-designs-query.d.ts.map +1 -1
- package/dist/types/subscriber/index.d.ts +1 -1
- package/dist/types/subscriber/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/wpcom-plans-ui/actions.d.ts +1 -1
- package/dist/types/wpcom-plans-ui/index.d.ts +1 -1
- package/dist/types/wpcom-plans-ui/index.d.ts.map +1 -1
- package/dist/types/wpcom-request-controls/index.d.ts +1 -1
- package/dist/types/wpcom-request-controls/index.d.ts.map +1 -1
- package/dist/types/wpcom-request.d.ts +7 -0
- package/dist/types/wpcom-request.d.ts.map +1 -0
- package/package.json +23 -22
- package/src/add-ons/types.ts +1 -0
- package/src/agents-manager/actions.ts +151 -0
- package/src/agents-manager/constants.ts +1 -0
- package/src/agents-manager/index.ts +38 -0
- package/src/agents-manager/persist-state.ts +60 -0
- package/src/agents-manager/reducer.ts +106 -0
- package/src/agents-manager/resolvers.ts +87 -0
- package/src/agents-manager/selectors.ts +32 -0
- package/src/agents-manager/test/persist-state.test.ts +81 -0
- package/src/agents-manager/test/reducer.test.ts +69 -0
- package/src/agents-manager/types.ts +24 -0
- package/src/contextual-help/admin-sections.ts +1 -1
- package/src/help-center/actions.ts +101 -76
- package/src/help-center/constants.ts +1 -0
- package/src/help-center/index.ts +11 -32
- package/src/help-center/reducer.ts +29 -5
- package/src/help-center/resolvers.ts +46 -38
- package/src/help-center/selectors.ts +3 -0
- package/src/help-center/test/utils.ts +99 -0
- package/src/help-center/types.ts +22 -13
- package/src/help-center/utils.ts +156 -0
- package/src/index.ts +11 -1
- package/src/mutations/use-domains-bulk-actions-mutation.ts +1 -1
- package/src/newsletter-categories/index.ts +1 -1
- package/src/newsletter-categories/test/index.tsx +5 -2
- package/src/onboard/actions.ts +7 -2
- package/src/onboard/reducer.ts +12 -2
- package/src/onboard/selectors.ts +1 -0
- package/src/plans/constants.ts +2 -0
- package/src/plans/hooks/test/use-pricing-meta-for-grid-plans.ts +120 -0
- package/src/plans/hooks/use-pricing-meta-for-grid-plans.ts +48 -18
- package/src/plans/index.ts +1 -0
- package/src/plans/queries/use-plans.ts +1 -1
- package/src/plans/queries/use-site-plans.ts +1 -1
- package/src/plans/resolvers.ts +0 -1
- package/src/plans/selectors.ts +9 -9
- package/src/plans/types.ts +6 -0
- package/src/products-list/queries/use-products.ts +1 -1
- package/src/products-list/resolvers.ts +1 -1
- package/src/products-list/selectors.ts +1 -1
- package/src/products-list/test/selectors.ts +2 -2
- package/src/purchases/lib/assembler.ts +10 -4
- package/src/purchases/queries/use-get-jetpack-transferred-license-purchases.tsx +1 -1
- package/src/purchases/queries/use-site-purchases.ts +2 -2
- package/src/purchases/types.ts +43 -0
- package/src/queries/use-all-domains-query.ts +3 -3
- package/src/queries/use-bulk-domain-update-status-query.ts +14 -115
- package/src/queries/use-happiness-engineers-query.ts +1 -1
- package/src/queries/use-launchpad.ts +1 -1
- package/src/queries/use-site-domains-query.ts +1 -1
- package/src/queries/use-site-intent.ts +1 -1
- package/src/queries/use-site-query.ts +1 -1
- package/src/reader/contexts/index.ts +0 -4
- package/src/reader/helpers/index.ts +3 -2
- package/src/reader/helpers/optimistic-update.ts +2 -1
- package/src/reader/index.ts +2 -4
- package/src/reader/mutations/test/use-site-subscription-mutations.test.tsx +208 -0
- package/src/reader/mutations/use-pending-site-confirm-mutation.ts +2 -2
- package/src/reader/mutations/use-site-delivery-frequency-mutation.ts +32 -36
- package/src/reader/mutations/use-site-email-me-new-comments-mutation.ts +10 -10
- package/src/reader/mutations/use-site-email-me-new-posts-mutation.ts +10 -10
- package/src/reader/mutations/use-site-notify-me-of-new-posts-mutation.ts +10 -10
- package/src/reader/mutations/use-site-subscribe-mutation.ts +21 -10
- package/src/reader/mutations/use-site-unsubscribe-mutation.ts +20 -10
- package/src/reader/queries/index.ts +4 -6
- package/src/reader/queries/test/use-site-subscriptions-query.tsx +158 -52
- package/src/reader/queries/use-site-subscriptions-query.ts +53 -55
- package/src/reader/types/index.ts +34 -48
- package/src/shared-types.ts +13 -0
- package/src/site/actions.ts +1 -1
- package/src/site/queries/use-site-features.ts +1 -1
- package/src/site/queries/use-site-media-storage.ts +1 -1
- package/src/site/queries/use-site-user-query.ts +1 -1
- package/src/site/queries/use-site.ts +1 -1
- package/src/site/resolvers.ts +1 -1
- package/src/site/selectors.ts +18 -10
- package/src/site/test/selectors.ts +3 -3
- package/src/site/types.ts +4 -1
- package/src/site-reset/test/use-site-reset-mutation.tsx +3 -4
- package/src/site-reset/use-site-reset-content-summary-query.ts +1 -1
- package/src/site-reset/use-site-reset-mutation.ts +1 -1
- package/src/site-reset/use-site-reset-status-query.ts +1 -1
- package/src/starter-designs-queries/types.ts +1 -1
- package/src/starter-designs-queries/use-starter-design-by-slug.ts +2 -2
- package/src/starter-designs-queries/use-starter-designs-query.ts +2 -2
- package/src/subscriber/actions.ts +1 -1
- package/src/templates/use-template.ts +1 -1
- package/src/users/use-send-invites.ts +1 -1
- package/src/utils.ts +33 -0
- package/src/wpcom-request-controls/index.ts +2 -1
- package/src/wpcom-request.ts +26 -0
- package/dist/cjs/reader/contexts/unsubscribed-feeds-search.js +0 -26
- package/dist/cjs/reader/contexts/unsubscribed-feeds-search.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-query.js +0 -21
- package/dist/cjs/reader/queries/use-read-feed-query.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-search-query.js +0 -39
- package/dist/cjs/reader/queries/use-read-feed-search-query.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-site-query.js +0 -26
- package/dist/cjs/reader/queries/use-read-feed-site-query.js.map +0 -1
- package/dist/esm/reader/contexts/unsubscribed-feeds-search.js +0 -20
- package/dist/esm/reader/contexts/unsubscribed-feeds-search.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-query.js +0 -18
- package/dist/esm/reader/queries/use-read-feed-query.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-search-query.js +0 -35
- package/dist/esm/reader/queries/use-read-feed-search-query.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-site-query.js +0 -23
- package/dist/esm/reader/queries/use-read-feed-site-query.js.map +0 -1
- package/dist/types/reader/contexts/unsubscribed-feeds-search.d.ts +0 -12
- package/dist/types/reader/contexts/unsubscribed-feeds-search.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-query.d.ts +0 -28
- package/dist/types/reader/queries/use-read-feed-query.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-search-query.d.ts +0 -34
- package/dist/types/reader/queries/use-read-feed-search-query.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-site-query.d.ts +0 -15
- package/dist/types/reader/queries/use-read-feed-site-query.d.ts.map +0 -1
- package/src/reader/contexts/unsubscribed-feeds-search.tsx +0 -35
- package/src/reader/queries/test/use-read-feed-search-query.tsx +0 -55
- package/src/reader/queries/use-read-feed-query.ts +0 -45
- package/src/reader/queries/use-read-feed-search-query.ts +0 -72
- package/src/reader/queries/use-read-feed-site-query.ts +0 -35
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
6
|
+
import { callApi } from '../helpers';
|
|
3
7
|
import {
|
|
4
8
|
alterSiteSubscriptionDetails,
|
|
5
9
|
invalidateSiteSubscriptionDetails,
|
|
6
10
|
} from '../helpers/optimistic-update';
|
|
7
11
|
import { useIsLoggedIn } from '../hooks';
|
|
8
|
-
import type {
|
|
12
|
+
import type { SiteSubscriptionDetails } from '../types';
|
|
9
13
|
|
|
10
14
|
type SiteSubscriptionEmailMeNewPostsParams = {
|
|
11
15
|
send_posts: boolean;
|
|
@@ -50,16 +54,12 @@ const useSiteEmailMeNewPostsMutation = () => {
|
|
|
50
54
|
return response;
|
|
51
55
|
},
|
|
52
56
|
onMutate: async ( { blog_id, send_posts, subscriptionId } ) => {
|
|
53
|
-
const siteSubscriptionsQueryKey =
|
|
54
|
-
[ 'read', 'site-subscriptions' ],
|
|
55
|
-
isLoggedIn,
|
|
56
|
-
id
|
|
57
|
-
);
|
|
57
|
+
const siteSubscriptionsQueryKey = getSiteSubscriptionsQueryKey();
|
|
58
58
|
|
|
59
59
|
await queryClient.cancelQueries( { queryKey: siteSubscriptionsQueryKey } );
|
|
60
60
|
|
|
61
61
|
const previousSiteSubscriptions =
|
|
62
|
-
queryClient.getQueryData<
|
|
62
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsQueryKey );
|
|
63
63
|
if ( previousSiteSubscriptions ) {
|
|
64
64
|
queryClient.setQueryData( siteSubscriptionsQueryKey, {
|
|
65
65
|
...previousSiteSubscriptions,
|
|
@@ -67,7 +67,7 @@ const useSiteEmailMeNewPostsMutation = () => {
|
|
|
67
67
|
return {
|
|
68
68
|
...page,
|
|
69
69
|
subscriptions: page.subscriptions.map( ( siteSubscription ) => {
|
|
70
|
-
if ( siteSubscription.blog_ID === blog_id ) {
|
|
70
|
+
if ( Number( siteSubscription.blog_ID ) === Number( blog_id ) ) {
|
|
71
71
|
return {
|
|
72
72
|
...siteSubscription,
|
|
73
73
|
delivery_methods: {
|
|
@@ -116,7 +116,7 @@ const useSiteEmailMeNewPostsMutation = () => {
|
|
|
116
116
|
onError: ( _err, _, context ) => {
|
|
117
117
|
if ( context?.previousSiteSubscriptions ) {
|
|
118
118
|
queryClient.setQueryData(
|
|
119
|
-
|
|
119
|
+
getSiteSubscriptionsQueryKey(),
|
|
120
120
|
context.previousSiteSubscriptions
|
|
121
121
|
);
|
|
122
122
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
6
|
+
import { callApi } from '../helpers';
|
|
3
7
|
import {
|
|
4
8
|
alterSiteSubscriptionDetails,
|
|
5
9
|
invalidateSiteSubscriptionDetails,
|
|
6
10
|
} from '../helpers/optimistic-update';
|
|
7
11
|
import { useIsLoggedIn } from '../hooks';
|
|
8
|
-
import type {
|
|
12
|
+
import type { SiteSubscriptionDetails } from '../types';
|
|
9
13
|
|
|
10
14
|
type SiteSubscriptionNotifyMeOfNewPostsParams = {
|
|
11
15
|
send_posts: boolean;
|
|
@@ -51,16 +55,12 @@ const useSiteNotifyMeOfNewPostsMutation = () => {
|
|
|
51
55
|
return response;
|
|
52
56
|
},
|
|
53
57
|
onMutate: async ( { blog_id, send_posts, subscriptionId } ) => {
|
|
54
|
-
const siteSubscriptionsQueryKey =
|
|
55
|
-
[ 'read', 'site-subscriptions' ],
|
|
56
|
-
isLoggedIn,
|
|
57
|
-
id
|
|
58
|
-
);
|
|
58
|
+
const siteSubscriptionsQueryKey = getSiteSubscriptionsQueryKey();
|
|
59
59
|
|
|
60
60
|
await queryClient.cancelQueries( { queryKey: siteSubscriptionsQueryKey } );
|
|
61
61
|
|
|
62
62
|
const previousSiteSubscriptions =
|
|
63
|
-
queryClient.getQueryData<
|
|
63
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsQueryKey );
|
|
64
64
|
|
|
65
65
|
if ( previousSiteSubscriptions ) {
|
|
66
66
|
queryClient.setQueryData( siteSubscriptionsQueryKey, {
|
|
@@ -69,7 +69,7 @@ const useSiteNotifyMeOfNewPostsMutation = () => {
|
|
|
69
69
|
return {
|
|
70
70
|
...page,
|
|
71
71
|
subscriptions: page.subscriptions.map( ( siteSubscription ) => {
|
|
72
|
-
if ( siteSubscription.blog_ID === blog_id ) {
|
|
72
|
+
if ( Number( siteSubscription.blog_ID ) === Number( blog_id ) ) {
|
|
73
73
|
return {
|
|
74
74
|
...siteSubscription,
|
|
75
75
|
delivery_methods: {
|
|
@@ -118,7 +118,7 @@ const useSiteNotifyMeOfNewPostsMutation = () => {
|
|
|
118
118
|
onError: ( err, _, context ) => {
|
|
119
119
|
if ( context?.previousSiteSubscriptions ) {
|
|
120
120
|
queryClient.setQueryData(
|
|
121
|
-
|
|
121
|
+
getSiteSubscriptionsQueryKey(),
|
|
122
122
|
context.previousSiteSubscriptions
|
|
123
123
|
);
|
|
124
124
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
6
|
import { buildQueryKey, callApi, getSubscriptionMutationParams, isValidId } from '../helpers';
|
|
3
7
|
import { useIsLoggedIn } from '../hooks';
|
|
4
|
-
import { SiteSubscriptionsPages } from '../types';
|
|
5
8
|
import type { SiteSubscriptionDetails } from '../types';
|
|
6
9
|
|
|
7
10
|
type SubscribeParams = {
|
|
@@ -20,6 +23,7 @@ type SubscribeResponse = {
|
|
|
20
23
|
success?: boolean;
|
|
21
24
|
subscribed?: boolean;
|
|
22
25
|
subscription?: {
|
|
26
|
+
ID: string;
|
|
23
27
|
blog_ID: string;
|
|
24
28
|
delivery_frequency: string;
|
|
25
29
|
status: string;
|
|
@@ -38,11 +42,7 @@ const buildSubscriptionDetailsByBlogIdQueryKey = (
|
|
|
38
42
|
const useSiteSubscribeMutation = () => {
|
|
39
43
|
const { isLoggedIn, id: userId } = useIsLoggedIn();
|
|
40
44
|
const queryClient = useQueryClient();
|
|
41
|
-
const siteSubscriptionsCacheKey =
|
|
42
|
-
[ 'read', 'site-subscriptions' ],
|
|
43
|
-
isLoggedIn,
|
|
44
|
-
userId
|
|
45
|
-
);
|
|
45
|
+
const siteSubscriptionsCacheKey = getSiteSubscriptionsQueryKey();
|
|
46
46
|
const subscriptionsCountCacheKey = buildQueryKey(
|
|
47
47
|
[ 'read', 'subscriptions-count' ],
|
|
48
48
|
isLoggedIn,
|
|
@@ -68,7 +68,8 @@ const useSiteSubscribeMutation = () => {
|
|
|
68
68
|
if ( ! response.subscribed ) {
|
|
69
69
|
throw new Error(
|
|
70
70
|
// reminder: translate this string when we add it to the UI
|
|
71
|
-
'Something went wrong while subscribing.'
|
|
71
|
+
'Something went wrong while subscribing.',
|
|
72
|
+
{ cause: response.info }
|
|
72
73
|
);
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -98,20 +99,30 @@ const useSiteSubscribeMutation = () => {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
const previousSiteSubscriptions =
|
|
101
|
-
queryClient.getQueryData<
|
|
102
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsCacheKey );
|
|
102
103
|
|
|
103
104
|
if ( previousSiteSubscriptions ) {
|
|
104
105
|
queryClient.setQueryData( siteSubscriptionsCacheKey, {
|
|
105
106
|
...previousSiteSubscriptions,
|
|
106
107
|
pages: previousSiteSubscriptions.pages.map( ( page ) => {
|
|
108
|
+
const shouldIncreaseTotalCount = page.subscriptions.some(
|
|
109
|
+
( siteSubscription ) =>
|
|
110
|
+
Number( siteSubscription.blog_ID ) === Number( params.blog_id ) &&
|
|
111
|
+
( siteSubscription.isDeleted || ! siteSubscription.is_following )
|
|
112
|
+
);
|
|
113
|
+
|
|
107
114
|
return {
|
|
108
115
|
...page,
|
|
109
|
-
|
|
116
|
+
totalCount:
|
|
117
|
+
typeof page.totalCount === 'number' && shouldIncreaseTotalCount
|
|
118
|
+
? page.totalCount + 1
|
|
119
|
+
: page.totalCount,
|
|
110
120
|
subscriptions: page.subscriptions.map( ( siteSubscription ) =>
|
|
111
|
-
siteSubscription.blog_ID === params.blog_id
|
|
121
|
+
Number( siteSubscription.blog_ID ) === Number( params.blog_id )
|
|
112
122
|
? {
|
|
113
123
|
...siteSubscription,
|
|
114
124
|
date_subscribed: new Date(),
|
|
125
|
+
is_following: true,
|
|
115
126
|
isDeleted: false,
|
|
116
127
|
resubscribed: params.resubscribed ?? false,
|
|
117
128
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
6
|
import { buildQueryKey, callApi, getSubscriptionMutationParams, isValidId } from '../helpers';
|
|
3
7
|
import { useCacheKey, useIsLoggedIn } from '../hooks';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
SubscriptionManagerSubscriptionsCount,
|
|
7
|
-
SiteSubscriptionDetails,
|
|
8
|
-
} from '../types';
|
|
8
|
+
import { SubscriptionManagerSubscriptionsCount, SiteSubscriptionDetails } from '../types';
|
|
9
|
+
import type { SiteSubscriptionItem } from '@automattic/api-core';
|
|
9
10
|
|
|
10
11
|
type UnsubscribeParams = {
|
|
11
12
|
subscriptionId: number;
|
|
@@ -46,7 +47,7 @@ const buildSiteSubscriptionDetailsQueryKey = (
|
|
|
46
47
|
const useSiteUnsubscribeMutation = () => {
|
|
47
48
|
const { isLoggedIn, id: userId } = useIsLoggedIn();
|
|
48
49
|
const queryClient = useQueryClient();
|
|
49
|
-
const siteSubscriptionsQueryKey =
|
|
50
|
+
const siteSubscriptionsQueryKey = getSiteSubscriptionsQueryKey();
|
|
50
51
|
const subscriptionsCountQueryKey = useCacheKey( [ 'read', 'subscriptions-count' ] );
|
|
51
52
|
|
|
52
53
|
return useMutation( {
|
|
@@ -93,21 +94,30 @@ const useSiteUnsubscribeMutation = () => {
|
|
|
93
94
|
await queryClient.cancelQueries( { queryKey: siteSubscriptionDetailsQueryKey } );
|
|
94
95
|
|
|
95
96
|
const previousSiteSubscriptions =
|
|
96
|
-
queryClient.getQueryData<
|
|
97
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsQueryKey );
|
|
97
98
|
|
|
98
99
|
// remove blog from site subscriptions
|
|
99
100
|
if ( previousSiteSubscriptions ) {
|
|
100
101
|
queryClient.setQueryData( siteSubscriptionsQueryKey, {
|
|
101
102
|
...previousSiteSubscriptions,
|
|
102
103
|
pages: previousSiteSubscriptions.pages.map( ( page ) => {
|
|
104
|
+
const isTargetSubscription = ( siteSubscription: SiteSubscriptionItem ) =>
|
|
105
|
+
Number( siteSubscription.ID ) === params.subscriptionId ||
|
|
106
|
+
( isValidId( params.blog_id ) &&
|
|
107
|
+
Number( siteSubscription.blog_ID ) === Number( params.blog_id ) );
|
|
108
|
+
const shouldDecrementTotalCount = page.subscriptions.some( isTargetSubscription );
|
|
109
|
+
|
|
103
110
|
return {
|
|
104
111
|
...page,
|
|
105
|
-
|
|
112
|
+
totalCount:
|
|
113
|
+
typeof page.totalCount === 'number' && shouldDecrementTotalCount
|
|
114
|
+
? page.totalCount - 1
|
|
115
|
+
: page.totalCount,
|
|
106
116
|
subscriptions: page.subscriptions.map( ( siteSubscription ) =>
|
|
107
|
-
|
|
108
|
-
( isValidId( params.blog_id ) && siteSubscription.blog_ID === params.blog_id ) //siteSubscription.blog_ID is not valid ID for non-wpcom subscriptions, so when unsubscribing from such site, the param.blog_id will also be not valid, this would create false positive
|
|
117
|
+
isTargetSubscription( siteSubscription )
|
|
109
118
|
? {
|
|
110
119
|
...siteSubscription,
|
|
120
|
+
is_following: false,
|
|
111
121
|
isDeleted: true,
|
|
112
122
|
resubscribed: false,
|
|
113
123
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
export { default as usePendingPostSubscriptionsQuery } from './use-pending-post-subscriptions-query';
|
|
2
2
|
export { default as usePendingSiteSubscriptionsQuery } from './use-pending-site-subscriptions-query';
|
|
3
3
|
export { default as usePostSubscriptionsQuery } from './use-post-subscriptions-query';
|
|
4
|
-
export { default as useReadFeedSearchQuery, FeedSort } from './use-read-feed-search-query';
|
|
5
|
-
export { default as useReadFeedSiteQuery } from './use-read-feed-site-query';
|
|
6
|
-
export { default as useReadFeedQuery } from './use-read-feed-query';
|
|
7
4
|
export { default as useSiteSubscriptionDetailsQuery } from './use-site-subscription-details-query';
|
|
8
5
|
export {
|
|
9
6
|
default as useSiteSubscriptionsQuery,
|
|
10
7
|
siteSubscriptionsQueryKeyPrefix,
|
|
11
8
|
} from './use-site-subscriptions-query';
|
|
12
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
default as useSubscriptionsCountQuery,
|
|
11
|
+
subscriptionsCountQueryKeyPrefix,
|
|
12
|
+
} from './use-subscriptions-count-query';
|
|
13
13
|
export { default as useUserSettingsQuery } from './use-user-settings-query';
|
|
14
|
-
|
|
15
|
-
export type { FeedItem } from './use-read-feed-search-query';
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
|
+
import {
|
|
5
|
+
getSiteSubscriptionsQueryKey,
|
|
6
|
+
type SiteSubscriptionsInfiniteData,
|
|
7
|
+
} from '@automattic/api-queries';
|
|
4
8
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
9
|
import { renderHook, waitFor } from '@testing-library/react';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { act } from 'react-dom/test-utils';
|
|
10
|
+
import React, { act } from 'react';
|
|
8
11
|
import { SiteSubscriptionsSortBy } from '../../constants';
|
|
9
12
|
import {
|
|
10
13
|
SiteSubscriptionsQueryPropsProvider,
|
|
@@ -12,8 +15,10 @@ import {
|
|
|
12
15
|
} from '../../contexts';
|
|
13
16
|
import { callApi, getSubkey } from '../../helpers';
|
|
14
17
|
import useSiteSubscriptionsQuery from '../../queries/use-site-subscriptions-query';
|
|
18
|
+
import type { SiteSubscriptionItem } from '../../types';
|
|
15
19
|
|
|
16
20
|
jest.mock( '../../helpers', () => ( {
|
|
21
|
+
...jest.requireActual( '../../helpers' ),
|
|
17
22
|
callApi: jest.fn(),
|
|
18
23
|
getSubkey: jest.fn(),
|
|
19
24
|
} ) );
|
|
@@ -26,60 +31,140 @@ const wrapper = ( { children } ) => (
|
|
|
26
31
|
</QueryClientProvider>
|
|
27
32
|
);
|
|
28
33
|
|
|
34
|
+
const makeFollow = ( overrides: Partial< SiteSubscriptionItem > = {} ): SiteSubscriptionItem => ( {
|
|
35
|
+
ID: '1',
|
|
36
|
+
URL: 'https://site1.example.com',
|
|
37
|
+
feed_URL: 'https://site1.example.com/feed',
|
|
38
|
+
blog_ID: '1',
|
|
39
|
+
feed_ID: '11',
|
|
40
|
+
is_following: true,
|
|
41
|
+
name: 'Site 1',
|
|
42
|
+
date_subscribed: new Date( '2024-01-01T00:00:00Z' ),
|
|
43
|
+
last_updated: new Date( '2024-01-01T00:00:00Z' ),
|
|
44
|
+
...overrides,
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
const makeApiSubscription = ( id: number ) => ( {
|
|
48
|
+
ID: String( id ),
|
|
49
|
+
URL: `https://site${ id }.example.com/feed`,
|
|
50
|
+
blog_ID: String( id ),
|
|
51
|
+
feed_ID: String( id + 1000 ),
|
|
52
|
+
name: `Site ${ id }`,
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
const makeSiteSubscriptionsData = (
|
|
56
|
+
pages: SiteSubscriptionItem[][],
|
|
57
|
+
totalCount = pages.reduce( ( count, page ) => count + page.length, 0 )
|
|
58
|
+
): SiteSubscriptionsInfiniteData => ( {
|
|
59
|
+
pages: pages.map( ( subscriptions, index ) => ( {
|
|
60
|
+
subscriptions,
|
|
61
|
+
totalCount,
|
|
62
|
+
page: index + 1,
|
|
63
|
+
number: 200,
|
|
64
|
+
} ) ),
|
|
65
|
+
pageParams: pages.map( ( _, index ) => index + 1 ),
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
const seedSiteSubscriptions = ( pages: SiteSubscriptionItem[][], totalCount?: number ) => {
|
|
69
|
+
queryClient.setQueryData< SiteSubscriptionsInfiniteData >(
|
|
70
|
+
getSiteSubscriptionsQueryKey(),
|
|
71
|
+
makeSiteSubscriptionsData( pages, totalCount )
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
29
75
|
describe( 'useSiteSubscriptionsQuery hook', () => {
|
|
30
76
|
beforeEach( () => {
|
|
31
77
|
queryClient.clear();
|
|
32
78
|
jest.resetAllMocks();
|
|
33
79
|
|
|
34
80
|
( getSubkey as jest.Mock ).mockReturnValue( () => 'test-key' );
|
|
81
|
+
( callApi as jest.Mock ).mockResolvedValue( {
|
|
82
|
+
subscriptions: [],
|
|
83
|
+
total_subscriptions: 0,
|
|
84
|
+
page: 1,
|
|
85
|
+
number: 200,
|
|
86
|
+
} );
|
|
35
87
|
} );
|
|
36
88
|
|
|
37
|
-
it( '
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
{
|
|
89
|
+
it( 'derives subscriptions data from multiple cached pages', async () => {
|
|
90
|
+
seedSiteSubscriptions( [
|
|
91
|
+
[
|
|
92
|
+
makeFollow( { ID: '1', name: 'Site 1', URL: 'https://site1.example.com' } ),
|
|
93
|
+
makeFollow( { ID: '2', name: 'Site 2', URL: 'https://site2.example.com' } ),
|
|
42
94
|
],
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
( callApi as jest.Mock ).mockResolvedValueOnce( {
|
|
47
|
-
subscriptions: [
|
|
48
|
-
{ id: '3', name: 'Site 3', URL: 'https://site3.example.com' },
|
|
49
|
-
{ id: '4', name: 'Site 4', URL: 'https://site4.example.com' },
|
|
95
|
+
[
|
|
96
|
+
makeFollow( { ID: '3', name: 'Site 3', URL: 'https://site3.example.com' } ),
|
|
97
|
+
makeFollow( { ID: '4', name: 'Site 4', URL: 'https://site4.example.com' } ),
|
|
50
98
|
],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
( callApi as jest.Mock ).mockResolvedValueOnce( {
|
|
55
|
-
subscriptions: [
|
|
56
|
-
{ id: '5', name: 'Site 5', URL: 'https://site5.example.com' },
|
|
57
|
-
{ id: '6', name: 'Site 6', URL: 'https://site6.example.com' },
|
|
99
|
+
[
|
|
100
|
+
makeFollow( { ID: '5', name: 'Site 5', URL: 'https://site5.example.com' } ),
|
|
101
|
+
makeFollow( { ID: '6', name: 'Site 6', URL: 'https://site6.example.com' } ),
|
|
58
102
|
],
|
|
59
|
-
|
|
60
|
-
total_subscriptions: 6,
|
|
61
|
-
} );
|
|
103
|
+
] );
|
|
62
104
|
|
|
63
|
-
const { result } = renderHook( () => useSiteSubscriptionsQuery(
|
|
105
|
+
const { result } = renderHook( () => useSiteSubscriptionsQuery(), {
|
|
64
106
|
wrapper,
|
|
65
107
|
} );
|
|
66
108
|
|
|
67
109
|
await waitFor( () => {
|
|
68
|
-
expect( callApi ).toHaveBeenCalledTimes( 3 );
|
|
69
110
|
expect( result.current.data.subscriptions.length ).toBe( 6 );
|
|
70
111
|
expect( result.current.data.totalCount ).toBe( 6 );
|
|
71
112
|
} );
|
|
72
113
|
} );
|
|
73
114
|
|
|
115
|
+
it( 'fetches additional pages through the subkey-aware API path', async () => {
|
|
116
|
+
// The server caps each page at 100 rows, so a full page is 100 items.
|
|
117
|
+
const firstPage = Array.from( { length: 100 }, ( _value, index ) =>
|
|
118
|
+
makeApiSubscription( index + 1 )
|
|
119
|
+
);
|
|
120
|
+
const secondPage = [ makeApiSubscription( 101 ) ];
|
|
121
|
+
|
|
122
|
+
( callApi as jest.Mock ).mockImplementation( ( { path, isLoggedIn } ) => {
|
|
123
|
+
expect( isLoggedIn ).toBe( false );
|
|
124
|
+
|
|
125
|
+
if ( path.includes( 'page=1' ) ) {
|
|
126
|
+
return Promise.resolve( {
|
|
127
|
+
subscriptions: firstPage,
|
|
128
|
+
total_subscriptions: 101,
|
|
129
|
+
page: 1,
|
|
130
|
+
number: 100,
|
|
131
|
+
} );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ( path.includes( 'page=2' ) ) {
|
|
135
|
+
return Promise.resolve( {
|
|
136
|
+
subscriptions: secondPage,
|
|
137
|
+
total_subscriptions: 101,
|
|
138
|
+
page: 2,
|
|
139
|
+
number: 1,
|
|
140
|
+
} );
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
throw new Error( `Unexpected path ${ path }` );
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
const { result } = renderHook( () => useSiteSubscriptionsQuery(), {
|
|
147
|
+
wrapper,
|
|
148
|
+
} );
|
|
149
|
+
|
|
150
|
+
await waitFor( () => expect( callApi ).toHaveBeenCalledTimes( 2 ) );
|
|
151
|
+
await waitFor( () => expect( result.current.data.subscriptions ).toHaveLength( 101 ) );
|
|
152
|
+
expect( ( callApi as jest.Mock ).mock.calls[ 0 ][ 0 ] ).toMatchObject( {
|
|
153
|
+
apiVersion: '1.2',
|
|
154
|
+
isLoggedIn: false,
|
|
155
|
+
} );
|
|
156
|
+
expect( ( callApi as jest.Mock ).mock.calls[ 0 ][ 0 ].path ).toContain(
|
|
157
|
+
'/read/following/mine'
|
|
158
|
+
);
|
|
159
|
+
} );
|
|
160
|
+
|
|
74
161
|
it( 'fetches subscriptions data with search term', async () => {
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
{
|
|
162
|
+
seedSiteSubscriptions( [
|
|
163
|
+
[
|
|
164
|
+
makeFollow( { ID: '1', name: 'Site 1', URL: 'https://site1.example.com' } ),
|
|
165
|
+
makeFollow( { ID: '2', name: 'Site 2', URL: 'https://site2.example.com' } ),
|
|
79
166
|
],
|
|
80
|
-
|
|
81
|
-
total_subscriptions: 2,
|
|
82
|
-
} );
|
|
167
|
+
] );
|
|
83
168
|
|
|
84
169
|
const { result } = renderHook(
|
|
85
170
|
() => {
|
|
@@ -97,12 +182,36 @@ describe( 'useSiteSubscriptionsQuery hook', () => {
|
|
|
97
182
|
act( () => result.current.setSearchTerm( 'te 1' ) );
|
|
98
183
|
await waitFor( () => expect( result.current.searchTerm ).toBe( 'te 1' ) );
|
|
99
184
|
|
|
100
|
-
expect( callApi ).toHaveBeenCalledTimes( 1 );
|
|
101
185
|
expect( result.current.data.subscriptions.length ).toBe( 1 );
|
|
102
186
|
expect( result.current.data.subscriptions[ 0 ].name ).toBe( 'Site 1' );
|
|
103
187
|
expect( result.current.data.totalCount ).toBe( 2 );
|
|
104
188
|
} );
|
|
105
189
|
|
|
190
|
+
it( 'reuses fresh cached follows when remounted', async () => {
|
|
191
|
+
seedSiteSubscriptions( [
|
|
192
|
+
[ makeFollow( { ID: '1', name: 'Site 1', URL: 'https://site1.example.com' } ) ],
|
|
193
|
+
] );
|
|
194
|
+
|
|
195
|
+
const firstRender = renderHook( () => useSiteSubscriptionsQuery(), {
|
|
196
|
+
wrapper,
|
|
197
|
+
} );
|
|
198
|
+
|
|
199
|
+
await waitFor( () => expect( firstRender.result.current.isLoading ).toBe( false ) );
|
|
200
|
+
expect( firstRender.result.current.data.subscriptions ).toHaveLength( 1 );
|
|
201
|
+
|
|
202
|
+
firstRender.unmount();
|
|
203
|
+
|
|
204
|
+
const secondRender = renderHook( () => useSiteSubscriptionsQuery(), {
|
|
205
|
+
wrapper,
|
|
206
|
+
} );
|
|
207
|
+
|
|
208
|
+
await waitFor( () =>
|
|
209
|
+
expect( secondRender.result.current.data.subscriptions ).toHaveLength( 1 )
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
expect( secondRender.result.current.data.subscriptions ).toHaveLength( 1 );
|
|
213
|
+
} );
|
|
214
|
+
|
|
106
215
|
it.each( [
|
|
107
216
|
{
|
|
108
217
|
sortTerm: SiteSubscriptionsSortBy.SiteName,
|
|
@@ -129,33 +238,31 @@ describe( 'useSiteSubscriptionsQuery hook', () => {
|
|
|
129
238
|
],
|
|
130
239
|
},
|
|
131
240
|
] )( 'Applies sorting to the subscriptions returned', async ( { sortTerm, expectedResult } ) => {
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
{
|
|
241
|
+
seedSiteSubscriptions( [
|
|
242
|
+
[
|
|
243
|
+
makeFollow( {
|
|
135
244
|
ID: '1',
|
|
136
245
|
name: "Zorro's site",
|
|
137
246
|
URL: 'https://site2.example.com',
|
|
138
|
-
date_subscribed: '2022-01-18T00:00:00+00:00',
|
|
139
|
-
last_updated: '2023-04-18T19:00:00+00:00',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
247
|
+
date_subscribed: new Date( '2022-01-18T00:00:00+00:00' ),
|
|
248
|
+
last_updated: new Date( '2023-04-18T19:00:00+00:00' ),
|
|
249
|
+
} ),
|
|
250
|
+
makeFollow( {
|
|
142
251
|
ID: '3',
|
|
143
252
|
name: "Maciej's site",
|
|
144
253
|
URL: 'https://site2.example.com',
|
|
145
|
-
date_subscribed: '2023-04-18T17:00:00+00:00',
|
|
146
|
-
last_updated: '2023-04-18T17:00:00+00:00',
|
|
147
|
-
},
|
|
148
|
-
{
|
|
254
|
+
date_subscribed: new Date( '2023-04-18T17:00:00+00:00' ),
|
|
255
|
+
last_updated: new Date( '2023-04-18T17:00:00+00:00' ),
|
|
256
|
+
} ),
|
|
257
|
+
makeFollow( {
|
|
149
258
|
ID: '2',
|
|
150
259
|
name: "Arnold's site",
|
|
151
260
|
URL: 'https://site1.example.com',
|
|
152
|
-
date_subscribed: '2023-04-18T12:00:00+00:00',
|
|
153
|
-
last_updated: '2023-04-18T12:00:00+00:00',
|
|
154
|
-
},
|
|
261
|
+
date_subscribed: new Date( '2023-04-18T12:00:00+00:00' ),
|
|
262
|
+
last_updated: new Date( '2023-04-18T12:00:00+00:00' ),
|
|
263
|
+
} ),
|
|
155
264
|
],
|
|
156
|
-
|
|
157
|
-
total_subscriptions: 3,
|
|
158
|
-
} );
|
|
265
|
+
] );
|
|
159
266
|
|
|
160
267
|
const { result } = renderHook(
|
|
161
268
|
() => {
|
|
@@ -172,7 +279,6 @@ describe( 'useSiteSubscriptionsQuery hook', () => {
|
|
|
172
279
|
act( () => result.current.setSortTerm( sortTerm ) );
|
|
173
280
|
await waitFor( () => expect( result.current.sortTerm ).toBe( sortTerm ) );
|
|
174
281
|
|
|
175
|
-
expect( callApi ).toHaveBeenCalledTimes( 1 );
|
|
176
282
|
result.current.data.subscriptions.forEach( ( subscription, index ) => {
|
|
177
283
|
expect( subscription.ID ).toEqual( expectedResult[ index ].ID );
|
|
178
284
|
} );
|