Skip to content

Commit

Permalink
WIP: Saving styles
Browse files Browse the repository at this point in the history
  • Loading branch information
ribaricplusplus committed Jan 10, 2023
1 parent 988ca70 commit da5a0e0
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ function UserVariation( { variation, userChangesMatchAnyVariation } ) {
const [ isFocused, setIsFocused ] = useState( false );
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
const associatedStyleId = user[ 'associated_style_id' ];
const { hasEditsForEntityRecord, hasFinishedResolution } =
useSelect( coreStore );
const { hasEditsForEntityRecord } = useSelect( coreStore );
const {
deleteEntityRecord,
__experimentalRefreshUserGlobalStylesVariations,
Expand Down Expand Up @@ -230,16 +229,6 @@ function UserVariation( { variation, userChangesMatchAnyVariation } ) {
};

const deleteStyleHandler = useCallback( () => {
if (
! hasFinishedResolution( 'getEditedEntityRecord', [
'root',
'globalStyles',
variation.id,
] )
) {
return;
}

// If this is the associated variation, remove the association
if ( associatedStyleId === variation.id ) {
setUserConfig( ( currentConfig ) => ( {
Expand All @@ -251,11 +240,7 @@ function UserVariation( { variation, userChangesMatchAnyVariation } ) {
deleteEntityRecord( 'root', 'globalStyles', variation.id ).then( () => {
__experimentalRefreshUserGlobalStylesVariations();
} );
}, [
variation,
associatedStyleId,
__experimentalRefreshUserGlobalStylesVariations,
] );
}, [ variation, associatedStyleId ] );

return (
<div
Expand Down

0 comments on commit da5a0e0

Please sign in to comment.