Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dataProvider hooks do not handle pageInfo when updating 'getList' query cache #8105

Merged
merged 3 commits into from
Aug 26, 2022

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented Aug 26, 2022

Problem:
The dataProvider hooks useUpdate, useUpdateMany, useDelete and useDeleteMany directly updates the 'getList' result when successful, but they did not handle the pageInfo. This lead to a pagination bug in EE module ra-editable-datagrid.

Bonus problem:
It also appears that the 'getList' cache was incorrectly populated by useUpdateMany, because fed with the list of ids as data, instead of the record data.

This lead to having cached values like:

{ id: 1, bar: 'baz', "0": 1, "1": 2 }

instead of:

{ id: 1, bar: 'baz' }

Solution:

  • All 4 hooks have been fixed to handle the pageInfo correctly
    • Notice: for now the value of this prop is determined in a very basic way: we just copy what was previously in cache. It might be doable to implement a more clever solution, but this seemed good enough to me for now...
  • The 4 hooks now use the real GetListResult type
  • useUpdateMany now calls updateCache with the proper data
  • unit tests have been added to all 4 hooks to ensure the cache is set properly

@slax57 slax57 added the RFR Ready For Review label Aug 26, 2022
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@djhi djhi added this to the 4.3.1 milestone Aug 26, 2022
@djhi djhi merged commit ef33656 into master Aug 26, 2022
@djhi djhi deleted the fix-dp-hooks-getList-cache-update branch August 26, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants