Skip to content

Replace useFileWithPath with simple query #3370

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

Merged
merged 7 commits into from
May 7, 2025
Merged

Replace useFileWithPath with simple query #3370

merged 7 commits into from
May 7, 2025

Conversation

JF-Cozy
Copy link
Contributor

@JF-Cozy JF-Cozy commented May 7, 2025

useFileWithPath and useFilesQueryWithPath were hooks that allowed, by querying the parent folder via the file's dir_id, to retrieve the parent's path and add it to an attribute called file.displayedFolder. We wanted to modify them because there is the queryDef buildParentsByIdsQuery([]) in them, which is suboptimal and will request all docs (because empty array passed to getByIds query).

Here, we rely on a simple query with a where clause that allows, through the stack, to directly retrieve a file with its path. From there, we create a simple method based on this path to determine the parent's path. Additionally, we avoid adding a 'virtual' attribute (file.displayedFolder) that is not on io.cozy.files.

JF-Cozy added 5 commits May 7, 2025 12:11
and make own parentFolderPath. Modifying the file doc wasn't a good approach in the first place anyway.
we exclude the trashed file and trash folder from the queries because that what's was done in the hook
`const resultData = (result.data || []).filter(file => file.dir_id !== TRASH_DIR_ID && file.trashed !== true)`
Copy link

bundlemon bot commented May 7, 2025

BundleMon

Files updated (2)
Status Path Size Limits
static/js/cozy.(hash).js
816.63KB (-78B -0.01%) -
static/js/main.(hash).js
114.15KB (-189B -0.16%) -
Unchanged files (19)
Status Path Size Limits
static/js/(chunkId).(hash).js
1.06MB -
public/static/js/(chunkId).(hash).js
859.38KB -
public/static/js/cozy.(hash).js
680.23KB -
(hash).js
337.62KB -
public/(hash).js
337.62KB -
services/qualificationMigration.js
273.84KB -
services/dacc.js
256.78KB -
public/static/js/public.(hash).js
85.33KB -
public/static/js/lib-react.(hash).js
39.37KB -
static/js/lib-react.(hash).js
39.37KB -
public/static/css/cozy.(hash).css
34.74KB -
static/css/cozy.(hash).css
34.74KB -
public/static/js/lib-router.(hash).js
22.05KB -
static/js/lib-router.(hash).js
22.05KB -
static/css/main.(hash).css
16.24KB -
public/static/css/public.(hash).css
5.59KB -
manifest.webapp
1.89KB -
index.html
688B -
assets/manifest.json
185B -

Total files change -275B -0.01%

Groups updated (1)
Status Path Size Limits
**/*.js
6.53MB (-336B 0%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.15MB -
**/*.css
131.37KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link
Member

@zatteo zatteo left a comment

Choose a reason for hiding this comment

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

Good work to remove the file.displayedFolder that was non standard.

@JF-Cozy JF-Cozy merged commit da8ae01 into master May 7, 2025
4 checks passed
@JF-Cozy JF-Cozy deleted the feat/query branch May 7, 2025 18:29
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.

3 participants