Skip to content

Commit

Permalink
Fix minor state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Jan 9, 2025
1 parent f36123d commit a813c5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions components/cacheExclusion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -26,6 +26,7 @@ const CacheExclusion = ( { methods, constants } ) => {
const handleExcludedUrlsChange = ( e ) => {
if ( e.target.value !== excludedUrls ) {
setIsEdited( true );
setIsSaved( false );
} else {
setIsEdited( false );
}
Expand All @@ -37,6 +38,7 @@ const CacheExclusion = ( { methods, constants } ) => {
const newValue = ! doNotCacheErrorPages;
setDoNotCacheErrorPages( newValue );
setIsEdited( true );
setIsSaved( false );
};

// Save settings to the API
Expand All @@ -63,7 +65,7 @@ const CacheExclusion = ( { methods, constants } ) => {
methods.useUpdateEffect( () => {
methods.setStore( {
...constants.store,
performance: {
cacheExclusion: {
excludedUrls,
doNotCacheErrorPages,
},
Expand Down
2 changes: 1 addition & 1 deletion includes/CacheExclusion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand Down

0 comments on commit a813c5c

Please sign in to comment.