Skip to content

Commit

Permalink
Explain when the legacy countries endpoint is used
Browse files Browse the repository at this point in the history
  • Loading branch information
myhro committed Feb 5, 2025
1 parent d0bf8f1 commit 41fb65b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ const StatsLocations: React.FC< StatsModuleLocationsProps > = ( { query, summary
enabled: ! shouldGate && supportsLocationsStatsFeature,
} );

const countriesViewsData = useSelector( ( state ) =>
// The legacy endpoint that only supports countries (not regions or cities)
// will be used when the new Locations Stats feature is not available.
const legacyCountriesViewsData = useSelector( ( state ) =>
getSiteStatsNormalizedData( state, siteId, statType, query )
) as [ id: number, label: string ];

const data = supportsLocationsStatsFeature ? locationsViewsData : countriesViewsData;
const data = supportsLocationsStatsFeature ? locationsViewsData : legacyCountriesViewsData;

// Only fetch separate countries list if we're not already in country tab
// This is to avoid fetching the same data twice.
Expand Down

0 comments on commit 41fb65b

Please sign in to comment.