Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use getValuesInBatch in post meta
  • Loading branch information
SantosGuillamot committed Jul 5, 2024
commit 98e718be3bf41357954c38b003c0155abd79ae43
18 changes: 18 additions & 0 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default {
getPlaceholder( { args } ) {
return args.key;
},
// When `getValuesInBatch` is defined, this is not running.
// Keeping it here to show the different possibilities.
getValue( { registry, context, args } ) {
return registry
.select( coreDataStore )
Expand All @@ -24,6 +26,22 @@ export default {
context?.postId
).meta?.[ args.key ];
},
getValuesInBatch( { registry, context, sourceBindings } ) {
const meta = registry
.select( coreDataStore )
.getEditedEntityRecord(
'postType',
context?.postType,
context?.postId
)?.meta;
const newValues = {};
for ( const [ attributeName, source ] of Object.entries(
sourceBindings
) ) {
newValues[ attributeName ] = meta?.[ source.args.key ];
}
return newValues;
},
// When `setValuesInBatch` is defined, this is not running.
// Keeping it here to show the different possibilities.
setValue( { registry, context, args, value } ) {
Expand Down