Make saveEditedEntityRecord use the entity key when available#36212
Make saveEditedEntityRecord use the entity key when available#36212
Conversation
|
Size Change: +10 B (0%) Total Size: 1.09 MB
ℹ️ View Unchanged
|
| if ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) { | ||
| return; | ||
| } | ||
| const entities = await dispatch( getKindEntities( kind ) ); |
There was a problem hiding this comment.
something feels weird here. should this be select or dispatch?
There was a problem hiding this comment.
@youknowriad I just copied this over from saveEntityRecord. getKindEntities is an action, probably because it calls entities = await kindConfig.loadEntities(); later on. I wonder if it could be a selector with a resolver instead? But that's something for another PR.
There was a problem hiding this comment.
gutenberg/packages/core-data/src/actions.js
Lines 383 to 395 in 88d2956
There was a problem hiding this comment.
Indeed I guess my old self is to blame for this confusion :P
There was a problem hiding this comment.
This code should actually be like:
const entities = await resolveSelect.getEntitiesByKind( kind );The getEntitiesByKind selector already exists, but it doesn't have a resolver attached. That needs to be fixed to make resolveSelect work. Now, we need to manually dispatch the getKindEntities action that fetches and populates the state read by getEntitiesByKind.
Description
Fixes a bug in
saveEditedEntityRecordwhich right now assumes that entity key is calledid. After the fix, it uses theentity.keyjust likesaveEntityRecord.How has this been tested?
Confirm all the tests pass.