Skip to content

Commit

Permalink
Tidy up the uncategorized condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Dec 18, 2023
1 parent 2136982 commit 7b5408f
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ export function PatternCategoryPreviews( {
return true;
}

if ( category.name !== 'uncategorized' ) {
return pattern.categories?.includes( category.name );
}
if ( category.name === 'uncategorized' ) {
// The uncategorized category should show all the patterns without any category...
if ( ! pattern.categories ) {
return true;
}

// The uncategorized category should show all the patterns without any category
// or with no available category.
if ( ! pattern.categories ) {
return true;
// ...or with no available category.
return ! pattern.categories.some( ( catName ) =>
availableCategories.some( ( c ) => c.name === catName )
);
}

return ! pattern.categories.some( ( catName ) =>
availableCategories.some( ( cat ) => cat.name === catName )
);
return pattern.categories?.includes( category.name );
} ),
[
allPatterns,
Expand Down

0 comments on commit 7b5408f

Please sign in to comment.