From 6b366c23900c8b37790c610948c8cb067f0f80c0 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Fri, 28 Jun 2024 11:38:27 +0200 Subject: [PATCH] CYS: fix flickering effect (#48767) * CYS: fix flickering effect * Add changefile(s) from automation for the following project(s): woocommerce * not use hook --------- Co-authored-by: github-actions --- .../sidebar/sidebar-navigation-screen-homepage-ptk.tsx | 8 ++------ .../sidebar/sidebar-navigation-screen-homepage.tsx | 8 ++------ .../assembler-hub/utils/is-tracking-allowed.ts | 1 + ...48728-cys-pop-up-effect-opt-in-tracking-section-notice | 4 ++++ 4 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 plugins/woocommerce-admin/client/customize-store/assembler-hub/utils/is-tracking-allowed.ts create mode 100644 plugins/woocommerce/changelog/48767-48728-cys-pop-up-effect-opt-in-tracking-section-notice diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage-ptk.tsx b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage-ptk.tsx index 77dbc9310ae..b46abc8a17e 100644 --- a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage-ptk.tsx +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage-ptk.tsx @@ -41,10 +41,10 @@ import { PATTERN_CATEGORIES } from './pattern-screen/categories'; import { capitalize } from 'lodash'; import { getNewPath, navigateTo } from '@woocommerce/navigation'; import { useSelect } from '@wordpress/data'; -import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { useNetworkStatus } from '~/utils/react-hooks/use-network-status'; import { isIframe, sendMessageToParent } from '~/customize-store/utils'; import { useEditorBlocks } from '../hooks/use-editor-blocks'; +import { isTrackingAllowed } from '../utils/is-tracking-allowed'; export const SidebarNavigationScreenHomepagePTK = ( { onNavigateBackClick, @@ -55,10 +55,6 @@ export const SidebarNavigationScreenHomepagePTK = ( { const isNetworkOffline = useNetworkStatus(); const isPTKPatternsAPIAvailable = context.isPTKPatternsAPIAvailable; - const trackingAllowed = useSelect( ( sel ) => - sel( OPTIONS_STORE_NAME ).getOption( 'woocommerce_allow_tracking' ) - ); - const isTrackingDisallowed = trackingAllowed === 'no' || ! trackingAllowed; const currentTemplate = useSelect( ( sel ) => @@ -113,7 +109,7 @@ export const SidebarNavigationScreenHomepagePTK = ( { "Unfortunately, we're experiencing some technical issues — please come back later to access more patterns.", 'woocommerce' ); - } else if ( isTrackingDisallowed ) { + } else if ( ! isTrackingAllowed() ) { notice = __( 'Opt in to usage tracking to get access to more patterns.', 'woocommerce' diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage.tsx b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage.tsx index 4738ff033fc..861a353b2fe 100644 --- a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage.tsx +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen-homepage.tsx @@ -49,9 +49,9 @@ import { } from '../utils/hero-pattern'; import { isEqual } from 'lodash'; import { COLOR_PALETTES } from './global-styles/color-palette-variations/constants'; -import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { useNetworkStatus } from '~/utils/react-hooks/use-network-status'; import { isIframe, sendMessageToParent } from '~/customize-store/utils'; +import { isTrackingAllowed } from '../utils/is-tracking-allowed'; const { GlobalStylesContext } = unlock( blockEditorPrivateApis ); @@ -223,10 +223,6 @@ export const SidebarNavigationScreenHomepage = ( { const isNetworkOffline = useNetworkStatus(); const isPTKPatternsAPIAvailable = context.isPTKPatternsAPIAvailable; - const trackingAllowed = useSelect( ( sel ) => - sel( OPTIONS_STORE_NAME ).getOption( 'woocommerce_allow_tracking' ) - ); - const isTrackingDisallowed = trackingAllowed === 'no' || ! trackingAllowed; let notice; if ( isNetworkOffline ) { @@ -239,7 +235,7 @@ export const SidebarNavigationScreenHomepage = ( { "Unfortunately, we're experiencing some technical issues — please come back later to access more patterns.", 'woocommerce' ); - } else if ( isTrackingDisallowed ) { + } else if ( ! isTrackingAllowed() ) { notice = __( 'Opt in to usage tracking to get access to more patterns.', 'woocommerce' diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/utils/is-tracking-allowed.ts b/plugins/woocommerce-admin/client/customize-store/assembler-hub/utils/is-tracking-allowed.ts new file mode 100644 index 00000000000..43e4d0dff8e --- /dev/null +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/utils/is-tracking-allowed.ts @@ -0,0 +1 @@ +export const isTrackingAllowed = () => window.wcTracks?.isEnabled || false; diff --git a/plugins/woocommerce/changelog/48767-48728-cys-pop-up-effect-opt-in-tracking-section-notice b/plugins/woocommerce/changelog/48767-48728-cys-pop-up-effect-opt-in-tracking-section-notice new file mode 100644 index 00000000000..f364fba2252 --- /dev/null +++ b/plugins/woocommerce/changelog/48767-48728-cys-pop-up-effect-opt-in-tracking-section-notice @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +CYS: fix flickering effect. \ No newline at end of file