Skip to content

Commit

Permalink
remove duplicate values
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed May 2, 2024
1 parent 2e07cac commit 57c7862
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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 57c7862

Please sign in to comment.