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

stack-client: Collections attributes duplication #1118

Open
Crash-- opened this issue Jan 27, 2022 · 3 comments
Open

stack-client: Collections attributes duplication #1118

Crash-- opened this issue Jan 27, 2022 · 3 comments

Comments

@Crash--
Copy link
Contributor

Crash-- commented Jan 27, 2022

Currently, when we duplicate all the attributes at the root of the object: https://github.com/cozy/cozy-client/blob/master/packages/cozy-stack-client/src/FileCollection.js#L66-L69

The result is that we have big object since we have twice all the attributes. Since attribute also contains cozyMetadata (https://docs.cozy.io/en/cozy-stack/files/#get-filesfile-id) it can be huge...

Also, when an io.cozy.files come from the Realtime, it doesn't have this attributes key because this attr is added by the stack on this special /files/ endpoint.

Comment from "ui": cozy/cozy-ui#2033 (comment)

@trollepierre trollepierre changed the title stack-client: FileCollection attributs duplication stack-client: FileCollection attributes duplication Jan 28, 2022
@paultranvan
Copy link
Contributor

This is not a problem restricted to the files but to other collections as well, AppCollection, ContactCollection, etc. So the issue is even worse

@paultranvan paultranvan changed the title stack-client: FileCollection attributes duplication stack-client: Collections attributes duplication Aug 2, 2022
cballevre added a commit that referenced this issue Jul 4, 2023
Real time provides an object with attributes at the root. When cozy-client merged it with the last request stored in the store, the properties were doubled with those in the object property. I decided to flatten the attributes property to have a single data source.

See also #1118
cballevre added a commit that referenced this issue Jul 4, 2023
Real time provides an object with attributes at the root. When cozy-client merged it with the last request stored in the store, the properties were doubled with those in the object property. I decided to flatten the attributes property to have a single data source.

See also #1118
@cballevre
Copy link
Member

cballevre commented Jul 4, 2023

I've encountered the same problem with SettingsCollection. I made a PR to temporarily fix the problem locally with duplication. I'm wondering how to make the transition to an api without attributes.

I thought we could :

  • add this attributes duplication logic to normalizeDoctypeJsonApi
  • add an 'attributes' depreciation (for example console.warn to get) to transition applications
  • do a breaking change to remove the attributes property

the disadvantage of this strategy is the temporary increase in the size of the redux store

how do you see it?

cballevre added a commit that referenced this issue Jul 4, 2023
Realtime provides an object with attributes at the root, whereas in query result, attributes are a property in themselves. When cozy-client tries to merge them, only the root attributes are updated. When normalising, I now spread attributes at the root so that I can access to a data that is always up to date.property. I decided to flatten the attributes property to have a single data source.

See also #1118
cballevre added a commit that referenced this issue Jul 4, 2023
Realtime provides an object with attributes at the root, whereas in query result, attributes are a property in themselves. When cozy-client tries to merge them, only the root attributes are updated. When normalising, I now spread attributes at the root so that I can access to a data that is always up to date.property. I decided to flatten the attributes property to have a single data source.

See also #1118
cballevre added a commit that referenced this issue Jul 4, 2023
Realtime provides an object with attributes at the root, whereas in query result, attributes are a property in themselves. When cozy-client tries to merge them, only the root attributes are updated. When normalising, I now spread attributes at the root so that I can access to a data that is always up to date.property. I decided to flatten the attributes property to have a single data source.

See also #1118
@Crash--
Copy link
Contributor Author

Crash-- commented Sep 29, 2023

I'm reading this issue again, and if I understand you correctly @cballevre at the end, we'll remove the existence of attributes everywhere? If yes, I don't know what to do for JSON-API response from cozy-stack that have this attributes fields.

Maybe we should resume what are the responses from the stack and see how we can handle them.

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

No branches or pull requests

3 participants