@@ -22,14 +22,15 @@ import Banner from 'calypso/components/banner';
22
22
import TrackComponentView from 'calypso/lib/analytics/track-component-view' ;
23
23
import { addQueryArgs } from 'calypso/lib/url' ;
24
24
import { canCurrentUser } from 'calypso/state/selectors/can-current-user' ;
25
+ import getPrimarySiteId from 'calypso/state/selectors/get-primary-site-id' ;
25
26
import getFeaturesBySiteId from 'calypso/state/selectors/get-site-features' ;
26
27
import isSiteAutomatedTransfer from 'calypso/state/selectors/is-site-automated-transfer' ;
27
28
import isSiteWPForTeams from 'calypso/state/selectors/is-site-wpforteams' ;
28
29
import isVipSite from 'calypso/state/selectors/is-vip-site' ;
29
30
import siteHasFeature from 'calypso/state/selectors/site-has-feature' ;
30
31
import { isSiteOnECommerceTrial , isSiteOnWooExpress } from 'calypso/state/sites/plans/selectors' ;
31
- import { getSite , isJetpackSite } from 'calypso/state/sites/selectors' ;
32
- import { getSelectedSiteId , getSelectedSiteSlug } from 'calypso/state/ui/selectors' ;
32
+ import { getSite , getSiteSlug , isJetpackSite } from 'calypso/state/sites/selectors' ;
33
+ import { getMostRecentlySelectedSiteId , getSelectedSiteId } from 'calypso/state/ui/selectors' ;
33
34
import type { SiteDetails } from '@automattic/data-stores' ;
34
35
import type { IsEligibleForOneClickCheckoutReturnValue } from 'calypso/my-sites/checkout/purchase-modal/use-is-eligible-for-one-click-checkout' ;
35
36
import type { IAppState } from 'calypso/state/types' ;
@@ -293,7 +294,10 @@ export const UpsellNudge = ( {
293
294
} ;
294
295
295
296
const ConnectedUpsellNudge = connect ( ( state : IAppState , ownProps : OwnProps ) => {
296
- const siteId = getSelectedSiteId ( state ) ;
297
+ const siteId =
298
+ getSelectedSiteId ( state ) ||
299
+ getMostRecentlySelectedSiteId ( state ) ||
300
+ getPrimarySiteId ( state ) ;
297
301
const siteFeatures = getFeaturesBySiteId ( state , siteId || undefined ) ;
298
302
const hasFeature =
299
303
siteFeatures === null ? null : siteHasFeature ( state , siteId , ownProps . feature || '' ) ;
@@ -308,8 +312,8 @@ const ConnectedUpsellNudge = connect( ( state: IAppState, ownProps: OwnProps ) =
308
312
isSiteWooExpressOrEcomFreeTrial : siteId
309
313
? isSiteOnECommerceTrial ( state , siteId ) || isSiteOnWooExpress ( state , siteId )
310
314
: false ,
311
- siteSlug : ownProps . disableHref ? null : getSelectedSiteSlug ( state ) ,
312
- siteIsWPForTeams : isSiteWPForTeams ( state , getSelectedSiteId ( state ) ) || false ,
315
+ siteSlug : ownProps . disableHref ? null : getSiteSlug ( state , siteId ) ,
316
+ siteIsWPForTeams : isSiteWPForTeams ( state , siteId ) || false ,
313
317
} ;
314
318
} ) ( UpsellNudge ) ;
315
319
0 commit comments