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

Homepage replacement on AT: Fix default behaviour #65846

Merged
merged 2 commits into from
Jul 22, 2022

Conversation

andres-blanco
Copy link
Contributor

@andres-blanco andres-blanco commented Jul 21, 2022

The current behaviour on Atomic is to always preserve the home page.
This PR sets the dont_change_homepage to true on the themes/mine POST request that is made when the Activate button is pressed. If this change is not added now, when this PR (1046-gh-Automattic/wpcomsh) is merged the default action would change on Atomic to "Always replace homepage" and we don't want that.

Testing

  1. Apply this PR.
  2. Go to a Simple site.
  3. Verify changing themes works as expected on its two flavors (replacing and preserving homepage).
  4. Go to an Atomic site.
  5. Verify changing themes preserves the homepage, the behaviour should be the same as WP.com.

@andres-blanco andres-blanco requested a review from a team July 21, 2022 15:05
@andres-blanco andres-blanco self-assigned this Jul 21, 2022
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 21, 2022
@github-actions
Copy link

github-actions bot commented Jul 21, 2022

@matticbot
Copy link
Contributor

matticbot commented Jul 21, 2022

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

Sections (~22 bytes added 📈 [gzipped])

name      parsed_size           gzip_size
themes          +22 B  (+0.0%)       +7 B  (+0.0%)
theme           +22 B  (+0.0%)       +8 B  (+0.0%)
checkout        +22 B  (+0.0%)       +7 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.

@andres-blanco andres-blanco force-pushed the fix/default-behaviour-homepage-replace-at branch from 12b5546 to fe7f435 Compare July 21, 2022 18:27
@mreishus
Copy link
Contributor

mreishus commented Jul 21, 2022

I don't fully understand what's happening here, but I noticed if I switch to a theme on an atomic site, and that theme hasn't been used on that site before, it uses this block of code which skips over the addition in this PR. Is that an issue?

If the theme has been installed before, I do see it using the new code and overriding keepCurrentHomepage.

@andres-blanco
Copy link
Contributor Author

andres-blanco commented Jul 22, 2022

I don't fully understand what's happening here, but I noticed if I switch to a theme on an atomic site, and that theme hasn't been used on that site before, it uses this block of code which skips over the addition in this PR. Is that an issue?

If the theme has been installed before, I do see it using the new code and overriding keepCurrentHomepage.

You are right. the value should be set before that conditional because all AT sites are JP sites. I will modify and retest, nice catch!.

@andres-blanco
Copy link
Contributor Author

andres-blanco commented Jul 22, 2022

I don't fully understand what's happening here

@mreishus It's kind of contrived but I will try to explain. On Simple when you click on 'Activate' you are presented with a modal that gives you two options, preserve or replace your homepage. This option is controlled by a strangely named POST arg called dont_change_homepage, if the user chooses to preserve then dont_change_homepage is true otherwise it's not even sent.
Currently when you click on 'Activate' on a theme on Atomic there's no modal and the behaviour defaults to preserving your content.

Adding this PR (1046-gh-Automattic/wpcomsh) to wpcomsh will do two things:

  • Enables the hooks on theme switch to replace the homepage if needed.
  • reads the dont_change_homepage arg and disables the home page replacement process (this process was copied almost verbatim from WPCOM).

The thing is that if the dont_change_homepage argument is not sent then the process can not be deactivated causing the home page to be replaced, changing the current default behaviour on Atomic. So I need this change to explicitly set dont_change_homepage to true.

Once the homepage modal is enabled in Atomic this will not be needed anymore.

@andres-blanco andres-blanco force-pushed the fix/default-behaviour-homepage-replace-at branch from fe7f435 to bbcde16 Compare July 22, 2022 15:23
Copy link
Contributor

@mreishus mreishus left a comment

Choose a reason for hiding this comment

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

Ok, makes sense. LGTM as I see no changes in behavior on either simple or atomic when changing themes.

@andres-blanco andres-blanco merged commit f503e13 into trunk Jul 22, 2022
@andres-blanco andres-blanco deleted the fix/default-behaviour-homepage-replace-at branch July 22, 2022 20:00
@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 Jul 22, 2022
@miksansegundo miksansegundo mentioned this pull request Feb 24, 2023
7 tasks
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.

3 participants