-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat: Non-primary images in a stack are sorted by file creation date #16346
base: main
Are you sure you want to change the base?
Conversation
//This is to make sure that the primary element is always the first one | ||
//It ensures consistency with the web version of the app where the primary element is always the first one | ||
final restElements = stackElements.sublist(1); | ||
restElements.sort((a, b) => a.fileCreatedAt.compareTo(b.fileCreatedAt)); |
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.
You're sorting it in the DB but you still need it here?
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.
It might not be needed, I did not check if it was still needed or not, however we might have an issue on the primary image because it needs to be first but isn't necessarily the earliest one in a time perspective. It's not an issue in the web version but on mobile the stackPrimaryAssetId is not defined if I recall correctly
I will rebuild the app to see if it is still needed, sorry about the oversight.
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.
Having the primary image be first is a general assumption we make in multiple places. The server needs to keep that behavior regardless.
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
)