-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: Non-primary images in a stack are sorted by file creation date #16346
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
Conversation
Some of the server's asset repository methods also have stack relations and need to be updated to reflect the change. I don't like how the ordering is handled in the mobile app and would have liked it to be handled in the DB query. If it's ordered in one direction, then it should be possible to order it the other direction as well, no? |
This is the query:
|
Thank you @mertalev , it works like a charm now ! |
Nice! Once the asset repo queries are updated, this PR should be good to go. |
Reverted a change when sorting in the asset queries, I will look into it in more details tomorrow |
I took a look at the server asset repositories but when querying an asset by ID you only have the stack Id, the primary assetId and the asset count, not the assets of the stack themselves. Is it really necessary to add ordering in the asset repository? I might be missing a query somewhere, but I don't know. |
Hey @mertalev , haven't been able to work on this PR recently but now I've got some time. |
So for example, |
Yeah that makes sense, but from what I can see in the code, the assets are squashed in the DTO anyway. Or we could add them back in the Stack Response with return {
id: entity.stack.id,
primaryAssetId: entity.stack.primaryAssetId,
assets: entity.stack.assets,
assetCount: entity.stack.assetCount ?? entity.stack.assets.length + 1,
}; In which case it would be useful to sort them as they would appear back in the API query |
Hey, I am going to close this for now due to it being stale for quite a long time. If you still have time to fix this and have more questions please feel free to comment on this PR still and we can have it re-opened 🙂 |
Description
Added sorting to the non primary images of a stack.
Since the mobile version behaves differently, the first one is extracted then the rest is sorted and both list are then reconcatenated.
This change addresses the issue of stack images ending up in a seemingly random order upon stacking.
Fixes #16250
How Has This Been Tested?
Stacks were made on 7 images with different dates, on both mobile and web version.
Stacks were created using increasingly recent dates (first one is the oldest file) and also using not the oldest as the first one to ensure it remained first after sorting on both mobile and web version
Stack more than 3 images, the first selected becomes the primary one
Navigate to stacked image
Confirm that the primary image remains first
Other images should be sorted by file creation date
Same test as above but selecting a file that is not the oldest or most recent of the stack, it should become the first in the stack viewer while the others are sorted
Screenshots (if appropriate)
File creation dates are as follow :
Checklist:
src/services
uses repositories implementations for database calls, filesystem operations, etc.src/repositories/
is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services
)