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

feat: Non-primary images in a stack are sorted by file creation date #16346

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Etienne-bdt
Copy link
Contributor

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 :

  • Dog : 2023/06/10 (selected first)
  • Monkey : 2021/04/06 - 10:17 am
  • Bread : 2021/04/06 - 11:16 am

web_stack
mobile_stack

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services)

@alextran1502 alextran1502 requested a review from mertalev March 3, 2025 16:24
@mertalev
Copy link
Contributor

mertalev commented Mar 3, 2025

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?

@mertalev
Copy link
Contributor

mertalev commented Mar 3, 2025

This is the query:

Future<List<Asset>> getStackAssets(String stackId) {

@Etienne-bdt
Copy link
Contributor Author

Thank you @mertalev , it works like a charm now !

@mertalev
Copy link
Contributor

mertalev commented Mar 3, 2025

Nice! Once the asset repo queries are updated, this PR should be good to go.

@Etienne-bdt
Copy link
Contributor Author

Reverted a change when sorting in the asset queries, I will look into it in more details tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong order when stacking photos.
4 participants