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 order preference #9135

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

martabal
Copy link
Member

@martabal martabal commented Apr 28, 2024

The goal is to have a new user settings to choose the default album order (the option is saved in db). The options are Backward and Forward.

Screenshots

User settings :
Screenshot from 2024-04-28 15-17-37

Copy link

cloudflare-pages bot commented Apr 28, 2024

Deploying immich with  Cloudflare Pages  Cloudflare Pages

Latest commit: d5d0258
Status: ✅  Deploy successful!
Preview URL: https://65c47480.immich.pages.dev
Branch Preview URL: https://feat-preference-album-order.immich.pages.dev

View logs

@martabal martabal force-pushed the feat/preference-album-order branch 15 times, most recently from bf804f1 to cd16415 Compare April 28, 2024 16:11
@martabal martabal force-pushed the feat/preference-album-order branch from cd16415 to ae17ea0 Compare April 29, 2024 22:06
@martabal martabal marked this pull request as ready for review April 30, 2024 21:33
@martabal martabal force-pushed the feat/preference-album-order branch from 1f7dc5b to d14e16e Compare April 30, 2024 21:44
Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

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

I like this much more now! Thank you :)

Comment on lines 92 to 94
if (order === AssetOrder.PREFERENCE) {
return enumToOrder[auth.user.preferedAlbumOrder];
}
Copy link
Member

Choose a reason for hiding this comment

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

This does not need to be in the outer if. You can simply move it in front of it :)

@@ -40,7 +41,9 @@ export class TimelineService {
private async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketOptions> {
const { userId, ...options } = dto;
let userIds: string[] | undefined = undefined;

if (dto?.order === AssetOrder.PREFERENCE) {
options.order = auth.user.preferedAlbumOrder as unknown as AssetOrder;
Copy link
Member

Choose a reason for hiding this comment

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

What is wrong with those types so that you need to cast it to unknown first?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's because we have

export enum AssetOrderPreference {
  ASC = 'asc',
  DESC = 'desc',
}

and

export enum AssetOrder {
  ASC = 'asc',
  DESC = 'desc',
  PREFERENCE = 'preference',
}

Copy link
Member

Choose a reason for hiding this comment

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

AssetOrderPreference is a subset of AssetOrder though, right? I don't understand why TS doesn't get this :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Extending an enum would be cool ...

@jrasm91
Copy link
Contributor

jrasm91 commented May 8, 2024

Why don't you convert this to ready for review after you have removed the per album/user sorting setting. I think we can keep the default sort order per person, and default to that setting for any new albums, but we don't need per user sort settings for each album.

@jrasm91 jrasm91 marked this pull request as draft May 8, 2024 03:47
@danieldietzler
Copy link
Member

Why don't you convert this to ready for review after you have removed the per album/user sorting setting. I think we can keep the default sort order per person, and default to that setting for any new albums, but we don't need per user sort settings for each album.

Martabal reverted that, no? Afaict this PR now only has (1) default setting per user and (2) sorting order per album (not per album per user).

@martabal
Copy link
Member Author

Yep, I think that's how we decided it to be 🤔

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

3 participants