From 866727e9f31bd98bde01df61a92676f6adb02744 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 28 Jun 2023 17:55:31 +1000 Subject: [PATCH] Patterns: Fix setting of sync status for fully synced patterns (#51952) --- .../edit-site/src/components/create-pattern-modal/index.js | 5 ++++- .../edit-site/src/components/page-library/use-patterns.js | 2 +- packages/editor/src/components/post-sync-status/index.js | 7 ++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/edit-site/src/components/create-pattern-modal/index.js b/packages/edit-site/src/components/create-pattern-modal/index.js index 2cef6b21ebbba..5180ad5d87068 100644 --- a/packages/edit-site/src/components/create-pattern-modal/index.js +++ b/packages/edit-site/src/components/create-pattern-modal/index.js @@ -54,7 +54,10 @@ export default function CreatePatternModal( { title: name || __( 'Untitled Pattern' ), content: '', status: 'publish', - meta: { sync_status: syncType }, + meta: + syncType === SYNC_TYPES.unsynced + ? { sync_status: syncType } + : undefined, }, { throwOnError: true } ); diff --git a/packages/edit-site/src/components/page-library/use-patterns.js b/packages/edit-site/src/components/page-library/use-patterns.js index 9034dc43421fc..6f3b7407e917d 100644 --- a/packages/edit-site/src/components/page-library/use-patterns.js +++ b/packages/edit-site/src/components/page-library/use-patterns.js @@ -145,7 +145,7 @@ const reusableBlockToPattern = ( reusableBlock ) => ( { categories: reusableBlock.wp_pattern, id: reusableBlock.id, name: reusableBlock.slug, - syncStatus: reusableBlock.meta?.sync_status, + syncStatus: reusableBlock.meta?.sync_status || SYNC_TYPES.full, title: reusableBlock.title.raw, type: reusableBlock.type, reusableBlock, diff --git a/packages/editor/src/components/post-sync-status/index.js b/packages/editor/src/components/post-sync-status/index.js index 40476111a82c1..392d33563ef78 100644 --- a/packages/editor/src/components/post-sync-status/index.js +++ b/packages/editor/src/components/post-sync-status/index.js @@ -26,13 +26,10 @@ export default function PostSyncStatus() { editPost( { meta: { ...meta, - wp_block: - syncStatus === 'unsynced' - ? { sync_status: syncStatus } - : null, + sync_status: syncStatus === 'unsynced' ? syncStatus : null, }, } ); - const syncStatus = meta?.wp_block?.sync_status; + const syncStatus = meta?.sync_status; const isFullySynced = ! syncStatus; return (