Skip to content

Commit

Permalink
DocumentBar: Only selected data needed for rendering (#61706)
Browse files Browse the repository at this point in the history
* DocumentBar: Only selected data needed for rendering
* Fix isNotFound condition

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored May 16, 2024
1 parent 15a6f89 commit 3c0c85d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ const MotionButton = motion( Button );
export default function DocumentBar() {
const {
postType,
document,
isResolving,
documentTitle,
isNotFound,
isUnsyncedPattern,
templateIcon,
templateTitle,
onNavigateToPreviousEntityRecord,
Expand All @@ -76,13 +77,16 @@ export default function DocumentBar() {
const _templateInfo = getTemplateInfo( _document );
return {
postType: _postType,
document: _document,
isResolving: isResolvingSelector(
'getEditedEntityRecord',
'postType',
_postType,
_postId
),
documentTitle: _document.title,
isNotFound:
! _document &&
! isResolvingSelector(
'getEditedEntityRecord',
'postType',
_postType,
_postId
),
isUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',
templateIcon: unlock( select( editorStore ) ).getPostIcon(
_postType,
{
Expand All @@ -98,12 +102,10 @@ export default function DocumentBar() {
const { open: openCommandCenter } = useDispatch( commandsStore );
const isReducedMotion = useReducedMotion();

const isNotFound = ! document && ! isResolving;
const isTemplate = TEMPLATE_POST_TYPES.includes( postType );
const isGlobalEntity = GLOBAL_POST_TYPES.includes( postType );
const hasBackButton = !! onNavigateToPreviousEntityRecord;
const title = isTemplate ? templateTitle : document.title;
const isUnsyncedPattern = document?.wp_pattern_sync_status === 'unsynced';
const title = isTemplate ? templateTitle : documentTitle;

const mounted = useRef( false );
useEffect( () => {
Expand Down

0 comments on commit 3c0c85d

Please sign in to comment.