Skip to content

Commit

Permalink
Fix bug with category duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Aug 25, 2023
1 parent 2c8caf5 commit dc66a2f
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
/**
* Internal dependencies
*/
import {
TEMPLATE_PARTS,
PATTERNS,
SYNC_TYPES,
USER_PATTERNS,
USER_PATTERN_CATEGORY,
} from './utils';
import { TEMPLATE_PARTS, PATTERNS, SYNC_TYPES, USER_PATTERNS } from './utils';
import {
useExistingTemplateParts,
getUniqueTemplatePartTitle,
Expand Down Expand Up @@ -149,7 +143,7 @@ export default function DuplicateMenuItem( {
__( '%s (Copy)' ),
item.title
);
const patternCategoryId = await findOrCreateTerm( categoryId );
const patternCategory = await findOrCreateTerm( categoryId );
const result = await saveEntityRecord(
'postType',
'wp_block',
Expand All @@ -160,7 +154,7 @@ export default function DuplicateMenuItem( {
meta: getPatternMeta( item ),
status: 'publish',
title,
wp_pattern_category: [ patternCategoryId ],
wp_pattern_category: [ patternCategory.id ],
},
{ throwOnError: true }
);
Expand All @@ -178,8 +172,8 @@ export default function DuplicateMenuItem( {
);

history.push( {
categoryType: USER_PATTERNS,
categoryId: USER_PATTERN_CATEGORY,
categoryType: PATTERNS,
categoryId,
postType: USER_PATTERNS,
postId: result?.id,
} );
Expand Down

0 comments on commit dc66a2f

Please sign in to comment.