Skip to content

Commit

Permalink
Taxonomies: use lodash's filter and avoid preloading check
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Sep 6, 2017
1 parent 4558414 commit 58c315e
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions editor/sidebar/post-taxonomies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External Dependencies
*/
import { connect } from 'react-redux';
import { flowRight } from 'lodash';
import { flowRight, filter } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -25,13 +25,7 @@ import { toggleSidebarPanel } from '../../actions';
const PANEL_NAME = 'post-taxonomies';

function PostTaxonomies( { postType, taxonomies, isOpened, onTogglePanel } ) {
const availableTaxonomies = !! taxonomies.data
? Object.values( taxonomies.data ).filter( ( taxonomy ) => taxonomy.types.indexOf( postType ) !== -1 )
: [];

if ( ! availableTaxonomies.length ) {
return null;
}
const availableTaxonomies = filter( taxonomies.data, ( taxonomy ) => taxonomy.types.indexOf( postType ) !== -1 );

return (
<PanelBody
Expand Down

0 comments on commit 58c315e

Please sign in to comment.