Skip to content
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

Newsletter: Only update jetpack form fields that are dirty #90294

Closed
wants to merge 1 commit into from

Conversation

enejb
Copy link
Member

@enejb enejb commented May 3, 2024

Currently when we save jetpack setting we make 2 endpoint calls.
1 for jetpack and other to the site settings endpoint.
This results in the same setting being saved twice.

This PR tries to fix this my calculating the settings that should only be saved via site setting endpoint and if there are any settings that are only to be saved via the jetpack settings then we use those settings.

This Pr intends to fix the #89109

Proposed Changes

  • Reduce the API requests to the jetpack settings endpoint. Since they are causing issues with the form fields saving the option multiple times.

Testing Instructions

  • For a jetpack site. Visit /settings/newsletter/example.com and notice that you are able to save all the different settings as expected.
  • Notice that only one POST request is made to the site as expected.
  • Since this change also applies to other Jetpack settings.
  • Navigate to other parts of calypso and notice that settings save as expected.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md 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 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 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)?

@enejb enejb added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Newsletters labels May 3, 2024
@enejb enejb requested review from okmttdhr, roo2 and a team May 3, 2024 21:11
@enejb enejb self-assigned this May 3, 2024
@matticbot
Copy link
Contributor

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

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

  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/newsletter-setting-saving on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented May 3, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~16 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
settings-writing            +39 B  (+0.0%)      +16 B  (+0.0%)
settings-security           +39 B  (+0.0%)      +16 B  (+0.0%)
settings-reading            +39 B  (+0.0%)      +16 B  (+0.0%)
settings-podcast            +39 B  (+0.0%)      +16 B  (+0.0%)
settings-performance        +39 B  (+0.0%)      +16 B  (+0.0%)
settings-newsletter         +39 B  (+0.0%)      +16 B  (+0.0%)
settings-discussion         +39 B  (+0.0%)      +16 B  (+0.0%)
settings                    +39 B  (+0.0%)      +16 B  (+0.0%)
people                      +39 B  (+0.0%)      +16 B  (+0.0%)
marketing                   +39 B  (+0.0%)      +16 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@pkuliga pkuliga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it and the error is gone, which is fine but it seems sometimes my changes are ignored.

When I refresh the page after a new toggle state has been saved it gets back to the original value.

toggleswitch.mov

Copy link
Member

@okmttdhr okmttdhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looked good to me except #90294 (review)

Linking to the PR describing settings save operations 🙂: #87695

@enejb
Copy link
Member Author

enejb commented May 11, 2024

Closing this in favour of #90605

@enejb enejb closed this May 11, 2024
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants