From a813c5cefa7a66903dee8360d8f06f084e8f1146 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Thu, 9 Jan 2025 18:53:07 +0530 Subject: [PATCH] Fix minor state updates --- components/cacheExclusion/index.js | 8 +++++--- includes/CacheExclusion.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/cacheExclusion/index.js b/components/cacheExclusion/index.js index b64495e..003b2ee 100644 --- a/components/cacheExclusion/index.js +++ b/components/cacheExclusion/index.js @@ -12,10 +12,10 @@ const CacheExclusion = ( { methods, constants } ) => { // Separate states for excluded URLs and error page exclusion const [ excludedUrls, setExcludedUrls ] = methods.useState( - methods.NewfoldRuntime.sdk.performance.excludedUrls || '' + methods.NewfoldRuntime.sdk.cacheExclusion.excludedUrls || '' ); const [ doNotCacheErrorPages, setDoNotCacheErrorPages ] = methods.useState( - methods.NewfoldRuntime.sdk.performance.doNotCacheErrorPages || false + methods.NewfoldRuntime.sdk.cacheExclusion.doNotCacheErrorPages || false ); const apiUrl = methods.NewfoldRuntime.createApiUrl( @@ -26,6 +26,7 @@ const CacheExclusion = ( { methods, constants } ) => { const handleExcludedUrlsChange = ( e ) => { if ( e.target.value !== excludedUrls ) { setIsEdited( true ); + setIsSaved( false ); } else { setIsEdited( false ); } @@ -37,6 +38,7 @@ const CacheExclusion = ( { methods, constants } ) => { const newValue = ! doNotCacheErrorPages; setDoNotCacheErrorPages( newValue ); setIsEdited( true ); + setIsSaved( false ); }; // Save settings to the API @@ -63,7 +65,7 @@ const CacheExclusion = ( { methods, constants } ) => { methods.useUpdateEffect( () => { methods.setStore( { ...constants.store, - performance: { + cacheExclusion: { excludedUrls, doNotCacheErrorPages, }, diff --git a/includes/CacheExclusion.php b/includes/CacheExclusion.php index 8249b86..551eb8a 100644 --- a/includes/CacheExclusion.php +++ b/includes/CacheExclusion.php @@ -44,7 +44,7 @@ public function __construct( Container $container ) { public function add_to_runtime( $sdk ) { $cache_exclusion = get_option( self::OPTION_CACHE_EXCLUSION, $this->get_default_cache_exclusion() ); - return array_merge( $sdk, $cache_exclusion ); + return array_merge( $sdk, array( 'cacheExclusion' => $cache_exclusion ) ); } /**