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 5 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)

//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));
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

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.
3 participants