From 5b45f0e349302ae6798738347070d763c5c4d08d Mon Sep 17 00:00:00 2001 From: Volodymyr Makukha Date: Fri, 23 Aug 2024 01:21:12 +0100 Subject: [PATCH] fix(hosting-overview-refinements): fix rendering atomic website as simple --- client/data/sites/use-site-excerpts-query.ts | 10 ++++++++++ .../hosting-features/components/hosting-features.tsx | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/client/data/sites/use-site-excerpts-query.ts b/client/data/sites/use-site-excerpts-query.ts index a1b40deb8d139..b651f7dba41f2 100644 --- a/client/data/sites/use-site-excerpts-query.ts +++ b/client/data/sites/use-site-excerpts-query.ts @@ -29,6 +29,16 @@ const fetchSites = ( } ); }; +export const queryKeyForAllSitesWithThemeSlug = [ + USE_SITE_EXCERPTS_QUERY_KEY, + SITE_EXCERPT_REQUEST_FIELDS, + SITE_EXCERPT_REQUEST_OPTIONS, + [], + 'all', + [], + [ 'theme_slug' ], +]; + export const useSiteExcerptsQuery = ( fetchFilter?: string[], sitesFilterFn?: ( site: SiteExcerptData ) => boolean, diff --git a/client/hosting/hosting-features/components/hosting-features.tsx b/client/hosting/hosting-features/components/hosting-features.tsx index 92c6f140c5efd..0f3080fd693be 100644 --- a/client/hosting/hosting-features/components/hosting-features.tsx +++ b/client/hosting/hosting-features/components/hosting-features.tsx @@ -3,6 +3,7 @@ import { FEATURE_SFTP, getPlan, PLAN_BUSINESS } from '@automattic/calypso-produc import page from '@automattic/calypso-router'; import { Dialog } from '@automattic/components'; import { useHasEnTranslation } from '@automattic/i18n-utils'; +import { useQueryClient } from '@tanstack/react-query'; import { Button, Spinner } from '@wordpress/components'; import { translate } from 'i18n-calypso'; import { useRef, useState, useEffect } from 'react'; @@ -10,6 +11,7 @@ import { AnyAction } from 'redux'; import EligibilityWarnings from 'calypso/blocks/eligibility-warnings'; import { HostingCard } from 'calypso/components/hosting-card'; import InlineSupportLink from 'calypso/components/inline-support-link'; +import { queryKeyForAllSitesWithThemeSlug } from 'calypso/data/sites/use-site-excerpts-query'; import { useSiteTransferStatusQuery } from 'calypso/landing/stepper/hooks/use-site-transfer/query'; import { useSelector, useDispatch } from 'calypso/state'; import { recordTracksEvent } from 'calypso/state/analytics/actions'; @@ -40,6 +42,7 @@ const PromoCard = ( { title, text, supportContext }: PromoCardProps ) => ( const HostingFeatures = () => { const dispatch = useDispatch(); + const queryClient = useQueryClient(); const { searchParams } = new URL( document.location.toString() ); const showActivationModal = searchParams.get( 'activate' ) !== null; const [ showEligibility, setShowEligibility ] = useState( showActivationModal ); @@ -91,8 +94,11 @@ const HostingFeatures = () => { if ( siteTransferData?.status === transferStates.COMPLETED ) { dispatch( fetchAtomicTransfer( siteId ) as unknown as AnyAction ); + queryClient.invalidateQueries( { + queryKey: queryKeyForAllSitesWithThemeSlug, + } ); } - }, [ siteTransferData?.status, siteId, dispatch ] ); + }, [ siteTransferData?.status, siteId, dispatch, queryClient ] ); const upgradeLink = `https://wordpress.com/checkout/${ encodeURIComponent( siteSlug ) }/business`; const promoCards = [