Skip to content

Commit

Permalink
make the condition check more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzj committed Jan 6, 2025
1 parent ad5841c commit 7ebf1ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/plugins/jetpack/_inc/client/traffic/site-stats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SiteStatsComponent extends React.Component {
wpcom_reader_views_enabled: props.getOptionValue( 'wpcom_reader_views_enabled' ),
};

if ( roles ) {
if ( roles?.length > 0 ) {
roles.forEach( role => {
if (
! [ 'administrator', 'editor', 'author', 'subscriber', 'contributor' ].includes( role )
Expand All @@ -52,7 +52,7 @@ class SiteStatsComponent extends React.Component {
} );
}

if ( countRoles ) {
if ( countRoles?.length > 0 ) {
countRoles.forEach( role => {
if (
! [ 'administrator', 'editor', 'author', 'subscriber', 'contributor' ].includes( role )
Expand Down

0 comments on commit 7ebf1ea

Please sign in to comment.