Skip to content

Commit

Permalink
Separate the Jetpack and WordPress banners
Browse files Browse the repository at this point in the history
As it's not necessary to load the code for both the Jetpack and WordPress banners, this commit separates them out into separate functions. They'll now only be called when necessary.
  • Loading branch information
Siobhan committed Aug 31, 2022
1 parent 28730f1 commit e385f51
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions client/blocks/app-banner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,10 @@ export class AppBanner extends Component {
return null;
}

render() {
const { translate, currentSection } = this.props;
if ( ! this.props.shouldDisplayAppBanner || this.state.isDraftPostModalShown ) {
return null;
}
getJetpackAppBanner = ( { translate, currentSection, isRtl } ) => {
const { title, copy, icon } = getAppBannerData( translate, currentSection, isRtl );

const { title, copy } = getAppBannerData( translate, currentSection );

const jetpackAppBanner = (
return (
<div className={ classNames( 'app-banner-overlay' ) } ref={ this.preventNotificationsClose }>
<Card
className={ classNames( 'app-banner', 'is-compact', currentSection, 'jetpack' ) }
Expand All @@ -171,7 +166,7 @@ export class AppBanner extends Component {
statGroup="calypso_mobile_app_banner"
statName="impression"
/>
<BannerIcon translate={ translate } currentSection={ currentSection } />
<BannerIcon icon={ icon } />
<div className="app-banner__text-content jetpack">
<div className="app-banner__title jetpack">
<span> { title } </span>
Expand All @@ -196,8 +191,12 @@ export class AppBanner extends Component {
</Card>
</div>
);
};

const wordpressAppBanner = (
getWordpressAppBanner = ( { translate, currentSection } ) => {
const { title, copy } = getAppBannerData( translate, currentSection );

return (
<div className={ classNames( 'app-banner-overlay' ) } ref={ this.preventNotificationsClose }>
<Card
className={ classNames( 'app-banner', 'is-compact', currentSection ) }
Expand Down Expand Up @@ -238,10 +237,18 @@ export class AppBanner extends Component {
</Card>
</div>
);
};

render() {
if ( ! this.props.shouldDisplayAppBanner || this.state.isDraftPostModalShown ) {
return null;
}

const displayJetpackAppBranding = config.isEnabled( 'jetpack/app-branding' );

return displayJetpackAppBranding ? jetpackAppBanner : wordpressAppBanner;
return displayJetpackAppBranding
? this.getJetpackAppBanner( this.props )
: this.getWordpressAppBanner( this.props );
}
}

Expand Down

0 comments on commit e385f51

Please sign in to comment.