Skip to content

Commit

Permalink
Do not load amount from local storage all the time except during onbo…
Browse files Browse the repository at this point in the history
…arding.
  • Loading branch information
asvinb committed Sep 27, 2024
1 parent 38d255a commit 5343963
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions js/src/components/paid-ads/ads-campaign/ads-campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function AdsCampaign( {
onStatesReceived={ handleOnStatesReceived }
campaign={ campaign }
countryCodes={ countryCodes }
loadCampaignFromClientSession={ isOnboardingFlow }
showCampaignPreviewCard={
trackingContext === 'setup-ads' ||
trackingContext === 'create-ads'

Check warning on line 157 in js/src/components/paid-ads/ads-campaign/ads-campaign.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/paid-ads/ads-campaign/ads-campaign.js#L156-L157

Added lines #L156 - L157 were not covered by tests
Expand Down
12 changes: 10 additions & 2 deletions js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ function resolveInitialPaidAds( paidAds ) {
* @param {Array<CountryCode>|undefined} props.countryCodes Country codes for the campaign.
* @param {Campaign} [props.campaign] Campaign data to be edited. If not provided, this component will show campaign creation UI.
* @param {boolean} [props.showCampaignPreviewCard=false] Whether to show the campaign preview card.
* @param {boolean} [props.loadCampaignFromClientSession=false] Whether to load the campaign data from the client session.
*/
export default function PaidAdsSetupSections( {
onStatesReceived,
countryCodes,
campaign,
loadCampaignFromClientSession,
showCampaignPreviewCard = false,

Check warning on line 73 in js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js#L73

Added line #L73 was not covered by tests
} ) {
const isCreation = ! campaign;

Check warning on line 75 in js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js#L75

Added line #L75 was not covered by tests
Expand All @@ -78,10 +80,16 @@ export default function PaidAdsSetupSections( {

const [ paidAds, setPaidAds ] = useState( () => {
// Resolve the starting paid ads data with the campaign data stored in the client session.
const startingPaidAds = {
let startingPaidAds = {

Check warning on line 83 in js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js#L83

Added line #L83 was not covered by tests
...defaultPaidAds,
...clientSession.getCampaign(),
};

if ( loadCampaignFromClientSession ) {
startingPaidAds = {

Check warning on line 88 in js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/paid-ads/ads-campaign/paid-ads-setup-sections.js#L88

Added line #L88 was not covered by tests
...startingPaidAds,
...clientSession.getCampaign(),
};
}
return resolveInitialPaidAds( startingPaidAds );
} );

Expand Down

0 comments on commit 5343963

Please sign in to comment.