Skip to content

Commit

Permalink
Instead of destructuring object, just send it. The global styles prov…
Browse files Browse the repository at this point in the history
…ider does the work.
  • Loading branch information
ramonjd committed Jun 12, 2024
1 parent faf5cba commit bf55b37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ function ScreenRevisions() {
};

const restoreRevision = ( revision ) => {
setUserConfig( () => ( {
styles: revision?.styles,
settings: revision?.settings,
_links: revision?._links,
} ) );
setUserConfig( () => revision );
setIsLoadingRevisionWithUnsavedChanges( false );
onCloseRevisions();
};
Expand Down Expand Up @@ -134,11 +130,7 @@ function ScreenRevisions() {
* See: https://github.com/WordPress/gutenberg/issues/55866
*/
if ( shouldSelectFirstItem ) {
setCurrentlySelectedRevision( {
styles: firstRevision?.styles || {},
settings: firstRevision?.settings || {},
id: firstRevision?.id,
} );
setCurrentlySelectedRevision( firstRevision );
}
}, [ shouldSelectFirstItem, firstRevision ] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,15 @@ export default function Variation( { variation, children, isPill } ) {
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
const context = useMemo(
() => ( {
user: {
settings: variation.settings ?? {},
styles: variation.styles ?? {},
_links: variation._links ?? {},
},
user: variation,
base,
merged: mergeBaseAndUserConfigs( base, variation ),
setUserConfig: () => {},
} ),
[ variation, base ]
);

const selectVariation = () => {
setUserConfig( () => ( {
settings: variation.settings,
styles: variation.styles,
_links: variation._links,
} ) );
};
const selectVariation = () => setUserConfig( () => variation );

const selectOnEnter = ( event ) => {
if ( event.keyCode === ENTER ) {
Expand Down

0 comments on commit bf55b37

Please sign in to comment.