Skip to content

Commit

Permalink
Boost: Remove global state from Purchase Success component (#33105)
Browse files Browse the repository at this point in the history
* Remove global state from PurchaseSuccess component

* add changelog
  • Loading branch information
dilirity committed Sep 18, 2023
1 parent 2fe76e5 commit e6fd13f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion projects/plugins/boost/app/assets/src/js/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

<Router history={routerHistory}>
<Route path="upgrade" component={BenefitsInterstitial} />
<Route path="purchase-successful" component={PurchaseSuccess} />
<Route path="purchase-successful" let:location let:navigate>
<PurchaseSuccess {location} {navigate} isImageGuideActive={$modulesState.image_guide.active} />
</Route>
<Route path="getting-started" component={GettingStarted} />
{#if $modulesState.image_size_analysis.available && $modulesState.image_size_analysis.active}
<Route path="image-size-analysis/:group/:page" component={RecommendationsPage} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
import ReactComponent from '../../elements/ReactComponent.svelte';
import TemplatedString from '../../elements/TemplatedString.svelte';
import { requestImageAnalysis } from '../../modules/image-size-analysis/store/isa-summary';
import { modulesState } from '../../stores/modules';
import Logo from '../../svg/jetpack-green.svg';
import enableCloudCss from '../../utils/enable-cloud-css';
import externalLinkTemplateVar from '../../utils/external-link-template-var';
const wpcomPricingUrl = getRedirectUrl( 'wpcom-pricing' );
// svelte-ignore unused-export-let - Ignored values supplied by svelte-navigator.
export let location, navigate;
export let isImageGuideActive: boolean;
onMount( async () => {
// Enable cloud css module on upgrade.
$modulesState.cloud_css.active = true;
enableCloudCss();
// If image guide is enabled, request a new ISA report.
if ( $modulesState.image_guide.active ) {
if ( isImageGuideActive ) {
// Check if images can be resized.
if ( false !== Jetpack_Boost.site.canResizeImages ) {
await requestImageAnalysis();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { modulesState } from '../stores/modules';

export default function enableCloudCss() {
// Enable cloud css module on upgrade.
modulesState.update( oldValue => {
return { ...oldValue, cloud_css: { ...oldValue.cloud_css, active: true } };
} );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Removed global state from Purchase Success component.


0 comments on commit e6fd13f

Please sign in to comment.