Skip to content

Commit

Permalink
Core Data: Use meta-store actions for status resolutions (#63469)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent 52b9831 commit 1b7e3a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
26 changes: 6 additions & 20 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,10 @@ export const getEntityRecords =
.filter( ( record ) => record?.[ key ] )
.map( ( record ) => [ kind, name, record[ key ] ] );

dispatch( {
type: 'START_RESOLUTIONS',
selectorName: 'getEntityRecord',
args: resolutionsArgs,
} );
dispatch( {
type: 'FINISH_RESOLUTIONS',
selectorName: 'getEntityRecord',
args: resolutionsArgs,
} );
dispatch.finishResolutions(
'getEntityRecord',
resolutionsArgs
);
}

dispatch.__unstableReleaseStoreLock( lock );
Expand Down Expand Up @@ -856,16 +850,8 @@ export const getRevisions =
record[ key ],
] );

dispatch( {
type: 'START_RESOLUTIONS',
selectorName: 'getRevision',
args: resolutionsArgs,
} );
dispatch( {
type: 'FINISH_RESOLUTIONS',
selectorName: 'getRevision',
args: resolutionsArgs,
} );
dispatch.startResolutions( 'getRevision', resolutionsArgs );
dispatch.finishResolutions( 'getRevision', resolutionsArgs );
}
}
};
Expand Down
15 changes: 5 additions & 10 deletions packages/core-data/src/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,12 @@ describe( 'getEntityRecords', () => {
} );

it( 'marks specific entity records as resolved', async () => {
const finishResolutions = jest.fn();
const dispatch = Object.assign( jest.fn(), {
receiveEntityRecords: jest.fn(),
__unstableAcquireStoreLock: jest.fn(),
__unstableReleaseStoreLock: jest.fn(),
finishResolutions,
} );
// Provide entities
dispatch.mockReturnValueOnce( ENTITIES );
Expand All @@ -230,16 +232,9 @@ describe( 'getEntityRecords', () => {
} );

// The record should have been received.
expect( dispatch ).toHaveBeenCalledWith( {
type: 'START_RESOLUTIONS',
selectorName: 'getEntityRecord',
args: [ [ ENTITIES[ 1 ].kind, ENTITIES[ 1 ].name, 2 ] ],
} );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'FINISH_RESOLUTIONS',
selectorName: 'getEntityRecord',
args: [ [ ENTITIES[ 1 ].kind, ENTITIES[ 1 ].name, 2 ] ],
} );
expect( finishResolutions ).toHaveBeenCalledWith( 'getEntityRecord', [
[ ENTITIES[ 1 ].kind, ENTITIES[ 1 ].name, 2 ],
] );
} );
} );

Expand Down

0 comments on commit 1b7e3a7

Please sign in to comment.