Skip to content

Commit

Permalink
Infer homeId
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed May 20, 2020
1 parent 7a9bcac commit 01adbb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/edit-site/src/components/template-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function TemplateLabel( { template, homeId } ) {
export default function TemplateSwitcher( {
ids,
activeId,
homeId,
isTemplatePart,
onActiveIdChange,
onActiveTemplatePartIdChange,
Expand All @@ -69,6 +68,13 @@ export default function TemplateSwitcher( {
const { currentTheme, templates, templateParts } = useSelect(
( select ) => {
const { getCurrentTheme, getEntityRecords } = select( 'core' );

const homeId = getEntityRecords( 'postType', 'wp_template', {
resolved: true,
slug: 'front-page',
theme: getCurrentTheme()?.stylesheet,
} )?.[ 0 ].id;

return {
currentTheme: getCurrentTheme(),
templates: getEntityRecords( 'postType', 'wp_template', {
Expand Down Expand Up @@ -96,8 +102,7 @@ export default function TemplateSwitcher( {
slug: templatePart.slug,
} ) ),
};
},
[ homeId ]
}
);
const [ isAddTemplateOpen, setIsAddTemplateOpen ] = useState( false );
return (
Expand Down

0 comments on commit 01adbb1

Please sign in to comment.