-
-
Notifications
You must be signed in to change notification settings - Fork 63
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 fetching album content when navigating #1388
Conversation
/backport to stable25 |
a9cca46
to
3bb10dc
Compare
...state.albumsFiles, | ||
[albumName]: [ | ||
...albumFiles, | ||
...fileIds.filter(fileId => !albumFiles.includes(fileId)), // Filter to prevent duplicate fileId. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really prefer using Set for performances reasons :)
https://jsben.ch/JNnpx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we address that later during a refactoring ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you made your point :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually already made the change in collectionStoreFactory
that I want to use for albums and share albums
photos/src/store/collectionStoreFactory.js
Lines 76 to 83 in fb218a1
[`addFilesTo${capitalizedCollectionName}`](state, { collectionId, fileIdsToAdd }) { | |
const collectionFiles = state[`${collectionName}sFiles`][collectionId] || [] | |
state[`${collectionName}sFiles`] = { | |
...state[`${collectionName}sFiles`], | |
[collectionId]: [...new Set([...collectionFiles, ...fileIdsToAdd])], | |
} | |
state[`${collectionName}s`][collectionId].nbItems += fileIdsToAdd.length | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But truth for truth, I am actually thinking of more generic store structure instead of having dedicated stores with collectionStoreFactory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But first, make it work, then optimize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we address that later during a refactoring ?
Absolutely 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there isn't some tools out there that can detect such things 🤔
That seems not too crazy. Easy recommendations tbh 🙈
Signed-off-by: Louis Chemineau <louis@chmn.me>
3bb10dc
to
e739e51
Compare
The backport to stable25 failed. Please do this backport manually. |
/backport to stable25 |
When navigating between albums:
newFileMenuEntry
was causing an error, because the entry were already existing as we did not remove it when destroyingAlbumContent
fetchAlbumContent
was never called as the album'sfileName
did not changeaddFilesToAlbum
was wrongly incrementing the items count, so I created another mutation calledsetAlbumFiles
that only set the album's files.