Skip to content

Commit

Permalink
Don't use fallback for context
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 24, 2024
1 parent f38d46b commit 8e6dd67
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,17 @@ export default {
).meta?.[ args.key ];
},
setValue( { registry, context, args, value } ) {
const postId =
context?.postId ||
registry.select( editorStore ).getCurrentPostId();
const postType =
context?.postType ||
registry.select( editorStore ).getCurrentPostType();
registry
.dispatch( coreDataStore )
.editEntityRecord( 'postType', postType, postId, {
.editEntityRecord( 'postType', context?.postType, context?.postId, {
meta: {
[ args.key ]: value,
},
} );
},
lockAttributesEditing( { select, context, args } ) {
const postId =
context?.postId || select( editorStore ).getCurrentPostId();
const postType =
context?.postType || select( editorStore ).getCurrentPostType();

// Check that editing is happening in the post editor and not a template.
if ( postType === 'wp_template' ) {
if ( context?.postType === 'wp_template' ) {
return true;
}

Expand All @@ -58,8 +47,8 @@ export default {
// Check that the user has the capability to edit post meta.
const canUserEdit = select( coreDataStore ).canUserEditEntityRecord(
'postType',
postType,
postId
context?.postType,
context?.postId
);
if ( ! canUserEdit ) {
return true;
Expand Down

0 comments on commit 8e6dd67

Please sign in to comment.