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(server, web): album orders #7819

Merged
merged 14 commits into from Mar 14, 2024
Merged

feat(server, web): album orders #7819

merged 14 commits into from Mar 14, 2024

Conversation

martabal
Copy link
Member

What's changed

This PR adds the ability to see album assets in ascending/descending order

Screenshots

2024-03-10.16-41-20.mp4

Copy link

cloudflare-pages bot commented Mar 10, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: b790fcc
Status: ✅  Deploy successful!
Preview URL: https://c699755e.immich.pages.dev
Branch Preview URL: https://feat-album-orders.immich.pages.dev

View logs

@martabal martabal force-pushed the feat/album-orders branch 2 times, most recently from 988b052 to 1162336 Compare March 10, 2024 15:54
@aviv926
Copy link
Contributor

aviv926 commented Mar 10, 2024

Fixing:
#7031
#6781
#6624

Maybe:
#7489
#1689

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have other existing query params, etc. We should use consistent naming here as well, not ascendingOrder. I think an enum would make more sense probably.

web/src/lib/components/album-page/album-options.svelte Outdated Show resolved Hide resolved
web/src/lib/components/photos-page/asset-grid.svelte Outdated Show resolved Hide resolved
web/src/lib/stores/assets.store.ts Outdated Show resolved Hide resolved
web/src/lib/components/album-page/album-options.svelte Outdated Show resolved Hide resolved
@martabal
Copy link
Member Author

I think an enum would make more sense probably

Something like this ?

enum Order {
  ASCENDING = 'ascending',
  DESCENDING = 'descending',
}

@jrasm91
Copy link
Contributor

jrasm91 commented Mar 11, 2024

I was referring to this, which we already have

image

@martabal martabal force-pushed the feat/album-orders branch 4 times, most recently from b43110e to 356a512 Compare March 11, 2024 23:16
mobile/pubspec.lock Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@@ -23,6 +23,8 @@ export class AlbumResponseDto {
startDate?: Date;
endDate?: Date;
isActivityEnabled!: boolean;
@ApiProperty({ enumName: 'AssetOrder', enum: AssetOrder })
order!: AssetOrder;
Copy link
Contributor

@jrasm91 jrasm91 Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenlong-tanwen will this new property break the mobile app? Do we need to make it order?: AssetOrder?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure it will break the mobile app because the SDK will check for this property and it will be null from previous version, so the users will not see any albums

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it optional then to avoid the breaking change. We can change it back in the future after a few releases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenlong-tanwen will this new property break the mobile app? Do we need to make it order?: AssetOrder?

Yes. The mobile app will not sync albums with older server versions. Making it optional would be best.

server/src/infra/entities/album.entity.ts Show resolved Hide resolved
@@ -598,7 +598,7 @@ export class AssetRepository implements IAssetRepository {
.select(`COUNT(asset.id)::int`, 'count')
.addSelect(truncated, 'timeBucket')
.groupBy(truncated)
.orderBy(truncated, 'DESC')
.orderBy(truncated, options.order === AssetOrder.ASC ? 'ASC' : 'DESC')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just do options.order.toUpperCase() instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about that. I don't like the idea of mixing SQL syntax and enum values

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ok that's fair. Coupling those would result in the query breaking in case we were to ever rename the enum value. That's actually bad, true!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as we add new values to this enum, we'll have to update that part too and I don't know if typescript / typeorm can alert it. It will definitely be a disaster 😆

web/src/lib/components/album-page/album-options.svelte Outdated Show resolved Hide resolved
web/src/lib/components/album-page/album-options.svelte Outdated Show resolved Hide resolved
@alextran1502
Copy link
Contributor

Hello, thank you for the PR!

I just ran some tests, and the order of the assets in the album doesn't seem to change. Can you double-check?

@martabal
Copy link
Member Author

Hello, thank you for the PR!

I just ran some tests, and the order of the assets in the album doesn't seem to change. Can you double-check?

Can you try with make open-api && make dev-update ?

@alextran1502
Copy link
Contributor

@martabal It works now, sorry about my glitchy system

@alextran1502
Copy link
Contributor

alextran1502 commented Mar 14, 2024

@martabal, actually, it doesn't work again, so there is probably a bug somewhere. Now, if you change the order, it changes once, and when you change it back, it doesn't register the change. I suspect your most recent commit 6de5367 has caused some issues

@martabal
Copy link
Member Author

Ok, it should be fixed

@alextran1502 alextran1502 merged commit 31f7e1a into main Mar 14, 2024
24 checks passed
@alextran1502 alextran1502 deleted the feat/album-orders branch March 14, 2024 16:45
@waclaw66
Copy link
Contributor

waclaw66 commented Mar 19, 2024

It would be nice to have Immich-wide or user-wide configuration for default album sorting. I personally prefer "oldest first" order for most of story-like albums, however timelapse albums looks better with "newest first" order.

@martabal
Copy link
Member Author

It would be nice to have Immich-wide or user-wide configuration for default album sorting. I personally prefer "oldest first" order for most of story-like albums, however timelapse albums looks better with "newest first" order.

User-wide makes sense. You probably can open a FR for that

@waclaw66
Copy link
Contributor

User-wide makes sense. You probably can open a FR for that

Created... #8068

@mondeg0
Copy link

mondeg0 commented Mar 21, 2024

This feature is awesome, and I was waiting for it for a long time!
However, the options to sort seems erased when the album is shared via a link. In this scenario, the album presentation is still recent to oldest, even if set to the inverse in the albums settings.

Is this a bug or desired behavior ?

@martabal
Copy link
Member Author

This is definitely a missing feature. We prefer to add features piece by piece, it's easier to correct bugs and get user feedback.

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.

None yet

8 participants