diff --git a/packages/editor/src/components/post-sync-status/index.js b/packages/editor/src/components/post-sync-status/index.js index bbc8cd0cfe974f..15e322b343f403 100644 --- a/packages/editor/src/components/post-sync-status/index.js +++ b/packages/editor/src/components/post-sync-status/index.js @@ -20,12 +20,21 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; import { store as editorStore } from '../../store'; import { unlock } from '../../lock-unlock'; +const { ReusableBlocksRenameHint } = unlock( blockEditorPrivateApis ); + export default function PostSyncStatus() { - const { syncStatus, postType, meta } = useSelect( ( select ) => { + const { syncStatus, postType } = useSelect( ( select ) => { const { getEditedPostAttribute } = select( editorStore ); + const meta = getEditedPostAttribute( 'meta' ); + + // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead. + const currentSyncStatus = + meta?.wp_pattern_sync_status === 'unsynced' + ? 'unsynced' + : getEditedPostAttribute( 'wp_pattern_sync_status' ); + return { - syncStatus: getEditedPostAttribute( 'wp_pattern_sync_status' ), - meta: getEditedPostAttribute( 'meta' ), + syncStatus: currentSyncStatus, postType: getEditedPostAttribute( 'type' ), }; } ); @@ -33,15 +42,12 @@ export default function PostSyncStatus() { if ( postType !== 'wp_block' ) { return null; } - // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead. - const currentSyncStatus = - meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : syncStatus; return ( { __( 'Sync status' ) }
- { currentSyncStatus === 'unsynced' + { syncStatus === 'unsynced' ? __( 'Not synced' ) : __( 'Fully synced' ) }
@@ -82,7 +88,7 @@ export function PostSyncStatusModal() { if ( postType !== 'wp_block' || ! isNewPost ) { return null; } - const { ReusableBlocksRenameHint } = unlock( blockEditorPrivateApis ); + return ( <> { isModalOpen && (