Skip to content

Commit

Permalink
Tweak to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Jul 7, 2023
1 parent 9362aef commit fee8340
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ import { unlock } from '../../lock-unlock';

const { useHistory } = unlock( routerPrivateApis );

function getPatternMeta( item ) {
if ( item.type === PATTERNS ) {
return { wp_pattern_sync_status: SYNC_TYPES.unsynced };
}

const syncStatus = item.reusableBlock.wp_pattern_sync_status;
const isUnsynced = syncStatus === SYNC_TYPES.unsynced;

return {
...item.reusableBlock.meta,
wp_pattern_sync_status: isUnsynced ? syncStatus : undefined,
};
}

export default function DuplicateMenuItem( {
categoryId,
item,
Expand Down Expand Up @@ -118,18 +132,7 @@ export default function DuplicateMenuItem( {
content: isThemePattern
? item.content
: item.reusableBlock.content,
meta: isThemePattern
? { wp_pattern_sync_status: SYNC_TYPES.unsynced }
: {
...item.reusableBlock.meta,
wp_pattern_sync_status:
item.reusableBlock
.wp_pattern_sync_status ===
SYNC_TYPES.unsynced
? item.reusableBlock
.wp_pattern_sync_status
: undefined,
},
meta: getPatternMeta( item ),
status: 'publish',
title,
},
Expand Down

0 comments on commit fee8340

Please sign in to comment.