Skip to content

Commit

Permalink
PostFormatSuggestion optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 19, 2020
1 parent 5a68cc8 commit ea7bbc7
Showing 1 changed file with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@ import { __, sprintf } from '@wordpress/i18n';
*/
import { POST_FORMAT_TITLES } from '../post-format';

const getSuggestion = ( supportedFormats, suggestedPostFormat ) => {
const formats = POST_FORMATS.filter( ( format ) =>
includes( supportedFormats, format.id )
);
return find( formats, ( format ) => format.id === suggestedPostFormat );
};

const PostFormatSuggestion = ( {
suggestedPostFormat,
suggestionText,
onUpdatePostFormat,
} ) => (
<Button isLink onClick={ () => onUpdatePostFormat( suggestedPostFormat ) }>
const PostFormatSuggestion = ( { onApplySuggestion, suggestionText } ) => (
<Button isLink onClick={ onApplySuggestion }>
{ suggestionText }
</Button>
);
Expand Down Expand Up @@ -57,10 +46,6 @@ export default function PostFormatPanel() {
return null;
}

function updatePostFormat( format ) {
editPost( { format } );
}

return (
<PanelBody
initialOpen={ false }
Expand All @@ -80,8 +65,9 @@ export default function PostFormatPanel() {
</p>
<p>
<PostFormatSuggestion
onUpdatePostFormat={ updatePostFormat }
suggestedPostFormat={ suggestedFormat }
onApplySuggestion={ () => {
editPost( { format: suggestedFormat } );
} }
suggestionText={ sprintf(
/* translators: %s: post format */
__( 'Apply the "%1$s" format.' ),
Expand Down

0 comments on commit ea7bbc7

Please sign in to comment.