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

Refactor Anontools #4845

Merged
merged 19 commits into from Jun 19, 2023
Merged

Refactor Anontools #4845

merged 19 commits into from Jun 19, 2023

Conversation

Tishasoumya-02
Copy link
Contributor

@Tishasoumya-02 Tishasoumya-02 commented Jun 6, 2023

@netlify
Copy link

netlify bot commented Jun 6, 2023

Deploy Preview for volto canceled.

Name Link
🔨 Latest commit 4d46640
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/648f13098ce8b500086b40f6

@cypress
Copy link

cypress bot commented Jun 6, 2023

Passing run #5731 ↗︎

0 503 20 0 Flakiness 0

Details:

Merge branch 'master' into refactor-anontools
Project: Volto Commit: 4d46640355
Status: Passed Duration: 16:16 💡
Started: Jun 18, 2023 2:25 PM Ended: Jun 18, 2023 2:41 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

src/hooks/anontools/anontools.js Outdated Show resolved Hide resolved
src/hooks/anontools/anontools.js Outdated Show resolved Hide resolved
@sneridagh
Copy link
Member

@Tishasoumya-02 @nileshgulia1 @JeffersonBledsoe @jackahl I've refactored the useContent hook. I'll explain later, but take a look at it.

@Tishasoumya-02
Copy link
Contributor Author

When destructing the return value of useContent ,unit tests were failing so reverted it back . I guess the prop Types are doing the work for it 🤔

import { useSelector, shallowEqual } from 'react-redux';

export function useContent() {
const data = useSelector((state) => state.content.data, shallowEqual);
Copy link
Member

Choose a reason for hiding this comment

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

@tiberiuichim what do you think of this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sneridagh I'm not sure, in principle is fine, but I have some concerns.

I'm genuinely curious about all the "ceremony", with multiple hook calls and shallowEqual. Why not just return state.content?

const content = useSelector((state) => state.content);
return {
  data: content.data,
  loading: content.get.loading,
  ...
}

I think that at this point, while we wait for useQuery, the hook is underpowered. It can't be used for content subrequests, which highlights the other problem: the hook right now only takes care of yielding content info, it doesn't trigger a getContent action.

Following this train of thought, I think it's better to either go full useQuery or not at all. If we introduce this, we'll have multiple variations of this type of code in the codebase (old style, useContent, etc), which will all have to be migrated to the new variation of useContent.

The counter-argument is that the useContent with subrequests is not needed in vanilla Volto, so it's fine to introduce it right now as it is and enhance it with params and options later.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the review! Let's try to talk today!

Copy link
Member

@nileshgulia1 nileshgulia1 left a comment

Choose a reason for hiding this comment

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

@sneridagh sneridagh merged commit ac3c119 into master Jun 19, 2023
53 checks passed
@sneridagh sneridagh deleted the refactor-anontools branch June 19, 2023 08:09
@sneridagh
Copy link
Member

Congrats! @Tishasoumya-02 The first one! 🎉 Let's continue for the rest!

sneridagh added a commit that referenced this pull request Jun 25, 2023
* master:
  Release 17.0.0-alpha.14
  Linked headlines (#3540)
  Release notes for 16.20.8 16.21.0 16.21.1 (#4910)
  Spanish translation (#4896)
  Refactor Anontools (#4845)
  Update to plone-backend 6.0.5 (#4897)
  Release 17.0.0-alpha.13
  Enforce max upload size (#4868)
  Fix and improve the `addStyling` helper (#4880)
  Release 17.0.0-alpha.12
  Fix regression in horizontal scroll in contents view, add it back (#4872)
  Configurable Container component from registry for some key route views. (#4871)
  Allow to deselect color in ColorPickerWidget. (#4839)
  Release 17.0.0-alpha.11
  Pagination with router params (#4698)
  Release 17.0.0-alpha.10
  feat(slate): Add css identifier to slate style menu options (#4847)
  Update Brazilian Portuguese translations (Fixes #4853)
  Convert header class to function (#4767)
sneridagh added a commit that referenced this pull request Jun 26, 2023
* master: (29 commits)
  Remove anonymous function calls. Remove default exports from. (#4917)
  Release 17.0.0-alpha.14
  Linked headlines (#3540)
  Release notes for 16.20.8 16.21.0 16.21.1 (#4910)
  Spanish translation (#4896)
  Refactor Anontools (#4845)
  Update to plone-backend 6.0.5 (#4897)
  Release 17.0.0-alpha.13
  Enforce max upload size (#4868)
  Fix and improve the `addStyling` helper (#4880)
  Release 17.0.0-alpha.12
  Fix regression in horizontal scroll in contents view, add it back (#4872)
  Configurable Container component from registry for some key route views. (#4871)
  Allow to deselect color in ColorPickerWidget. (#4839)
  Release 17.0.0-alpha.11
  Pagination with router params (#4698)
  Release 17.0.0-alpha.10
  feat(slate): Add css identifier to slate style menu options (#4847)
  Update Brazilian Portuguese translations (Fixes #4853)
  Convert header class to function (#4767)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants