Skip to content

Commit

Permalink
remove duplicate values
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Apr 12, 2024
1 parent 8c52299 commit 6680eb1
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ export default function useThemeStyleVariationsByProperty( {
result
);
}

// Detect if this is a duplicate variation.
const isDuplicate = accumulator.some( ( item ) => {
return (
JSON.stringify( item.styles ) ===
JSON.stringify( result?.styles ) &&
JSON.stringify( item.settings ) ===
JSON.stringify( result?.settings )
);
} );
if ( isDuplicate ) {
return accumulator;
}

// If the variation is not a duplicate, add it to the accumulator.
accumulator.push( result );
return accumulator;
},
Expand Down

0 comments on commit 6680eb1

Please sign in to comment.