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

Settings: Fix useSiteCopy features requesting selector #98583

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Jan 20, 2025

Proposed Changes

Updates useSiteCopy hook to use the isRequestingSiteFeatures selector instead of building a custom one and returning a new object on every run.

This also improves the code quality: we already have a dedicated selector for this, so we should be using it.

Introduced previously in #72714.

Why are these changes being made?

To reduce the number of rerenders on the Settings > General page and resolve this warning:

Screenshot 2025-01-20 at 10 05 02

Testing Instructions

@tyxla tyxla added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Site Settings All other general site settings. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 20, 2025
@tyxla tyxla requested review from sejas and a team January 20, 2025 08:10
@tyxla tyxla self-assigned this Jan 20, 2025
@matticbot
Copy link
Contributor

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

Sections (~6 bytes added 📈 [gzipped])

name            parsed_size           gzip_size
copy-site-flow       +181 B  (+0.0%)      +44 B  (+0.0%)
site-settings         -41 B  (-0.0%)      -10 B  (-0.0%)
settings              -41 B  (-0.0%)      -10 B  (-0.0%)
home                  -41 B  (-0.0%)      -28 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
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

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

Looks good. But an even better solution will be to finish #94840 🙂

The features.active field is already available on the site object, the features don't need to be fetched separately. #94840 also modifies useSiteCopy, you can see there how the code should eventually look like.

It turns out that the approach in #94840 is probably too ambitious: modify the siteHasFeature/getSiteFeatures selector, update the 30+ usage places to stop fetching, and test that none of them are broken.

We'll be better of doing something else: introduce new selectors, like siteHasFeatureEx and getSiteFeaturesEx, and start using these selectors at one place at a time. And do the migration gradually.

@tyxla
Copy link
Member Author

tyxla commented Jan 20, 2025

Looks good. But an even better solution will be to finish #94840 🙂

The features.active field is already available on the site object, the features don't need to be fetched separately. #94840 also modifies useSiteCopy, you can see there how the code should eventually look like.

It turns out that the approach in #94840 is probably too ambitious: modify the siteHasFeature/getSiteFeatures selector, update the 30+ usage places to stop fetching, and test that none of them are broken.

We'll be better of doing something else: introduce new selectors, like siteHasFeatureEx and getSiteFeaturesEx, and start using these selectors at one place at a time. And do the migration gradually.

I agree 👍 One step at a time, and I always prefer small steps.

Thanks for taking a look!

@tyxla tyxla merged commit 0e11795 into trunk Jan 20, 2025
17 checks passed
@tyxla tyxla deleted the fix/use-site-copy-requesting-features branch January 20, 2025 10:06
@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 Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Settings All other general site settings. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants