Skip to content

Commit

Permalink
improve readibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Nov 25, 2024
1 parent ffdcc1d commit e395bf6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
15 changes: 8 additions & 7 deletions packages/edit-site/src/components/editor/use-editor-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ function useEditorTitle( postType, postId ) {
postId
);

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_types || [];
const {
default_template_part_areas: templateAreas = [],
default_template_types: templateTypes = [],
} =
select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
) ?? {};

const templateInfo = getTemplateInfo( {
template: _record,
Expand Down
12 changes: 6 additions & 6 deletions packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ export default function DocumentBar( props ) {
_postId
);

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_part_areas || [];
const {
default_template_part_areas: templateAreas = [],
default_template_types: templateTypes = [],
} =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' ) ??
{};

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_types || [];
const _templateInfo = getTemplateInfo( {
templateAreas,
templateTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ export default function EntityRecordItem( { record, checked, onChange } ) {
key
);

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_types || [];
const {
default_template_part_areas: templateAreas = [],
default_template_types: templateTypes = [],
} =
select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
) ?? {};

return {
entityRecordTitle: getTemplateInfo( {
Expand Down
15 changes: 8 additions & 7 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ export default function PostCardPanel( {
postId
);

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.default_template_types || [];
const {
default_template_part_areas: templateAreas = [],
default_template_types: templateTypes = [],
} =
select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
) ?? {};

const _templateInfo = [
TEMPLATE_POST_TYPE,
Expand Down

0 comments on commit e395bf6

Please sign in to comment.