Skip to content

feat(server): visibility column #17939

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

Merged
merged 12 commits into from
May 6, 2025
Merged

feat(server): visibility column #17939

merged 12 commits into from
May 6, 2025

Conversation

alextran1502
Copy link
Member

No description provided.

@alextran1502 alextran1502 force-pushed the private-view-1 branch 3 times, most recently from 03f6c3c to 9169598 Compare April 28, 2025 21:54
@alextran1502 alextran1502 marked this pull request as draft April 29, 2025 05:29
@alextran1502 alextran1502 force-pushed the private-view-1 branch 4 times, most recently from 7820549 to d0e75c3 Compare April 29, 2025 17:03
@alextran1502 alextran1502 force-pushed the private-view-1 branch 2 times, most recently from 8d93dbd to 14f5b05 Compare April 29, 2025 19:38
and "assets"."isVisible" = $1
and "assets"."visibility" = $1
Copy link
Member

@mertalev mertalev Apr 29, 2025

Choose a reason for hiding this comment

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

isVisible is a mechanism to handle live photos while visibility is to handle which pages an asset should be viewable from. If the effective page visibility comes from the image part, you need to be very careful when linking and unlinking them.

Comment on lines -787 to +791
if (!isSync && (!asset.isVisible || asset.sidecarPath) && !asset.isExternal) {
if (!isSync && (asset.visibility === AssetVisibility.HIDDEN || asset.sidecarPath) && !asset.isExternal) {
Copy link
Member

Choose a reason for hiding this comment

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

May not be an issue in practice, but there may have been cases where booleans like isVisible were not present in the object and comparisons were just operating on truthiness. If there are any cases like this in the client or server, these equality comparisons would be a change in behavior. Shouldn't happen theoretically but could be good to keep in mind.

@alextran1502 alextran1502 force-pushed the private-view-1 branch 2 times, most recently from 42c3bf3 to 67ae3e7 Compare April 29, 2025 22:20
@alextran1502 alextran1502 force-pushed the private-view-1 branch 2 times, most recently from ce877c0 to 9649ec5 Compare May 1, 2025 14:25
@alextran1502 alextran1502 force-pushed the private-view-1 branch 2 times, most recently from 2aabb09 to 0be57cf Compare May 1, 2025 19:28
@alextran1502 alextran1502 marked this pull request as ready for review May 2, 2025 04:47
@alextran1502 alextran1502 requested review from jrasm91 and mertalev May 2, 2025 17:31
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.

This PR is quite hard to review actually, since so many queries are affected. From what I can tell you're changing the semantics of a bunch of queries (some of them I flagged, though most likely not all), which isn't ideal and should be done in a later PR if we actually consider the current semantics "wrong".
The issue is that it's already quite hard making sure the new query still has the same meaning as the previous query. Adding extra mental overhead by also re-thinking logic shouldn't be in here IMO

@alextran1502
Copy link
Member Author

@jrasm91 @danieldietzler @mertalev Queries' semantics should be preserved. The PR is ready for review again

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.

Looks much better!

@@ -393,7 +392,7 @@ export class AssetRepository {
.whereRef('stacked.stackId', '=', 'asset_stack.id')
.whereRef('stacked.id', '!=', 'asset_stack.primaryAssetId')
.where('stacked.deletedAt', 'is', null)
.where('stacked.isArchived', '=', false)
.where('stacked.visibility', '=', AssetVisibility.TIMELINE)
Copy link
Member

Choose a reason for hiding this comment

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

We used to be including hidden assets here as well, though they'd fly out in the join anyways afaict. Not 100% though.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mertalev Do you have any comments about this query?

Copy link
Member

Choose a reason for hiding this comment

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

It should be fine to filter for timeline assets. It's kind of debatable whether archived or trashed assets should also be included here since getById doesn't filter for them in the top level asset, but the PR effectively maintains the current behavior here.

Copy link
Member

@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.

LGTM

@@ -542,7 +548,15 @@ export class AssetRepository {
.select(truncatedDate<Date>(options.size).as('timeBucket'))
.$if(!!options.isTrashed, (qb) => qb.where('assets.status', '!=', AssetStatus.DELETED))
.where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null)
.where('assets.isVisible', '=', true)
.$if(options.visibility === undefined, (qb) =>
Copy link
Member

Choose a reason for hiding this comment

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

wow, you have this same thing like 5 times, which might have to change in the future. can you make a utility method like $if(visibility !== undefined, withDefaultVisibility) or something?

@alextran1502 alextran1502 merged commit d33ce13 into main May 6, 2025
51 checks passed
@alextran1502 alextran1502 deleted the private-view-1 branch May 6, 2025 17:12
savely-krasovsky pushed a commit to savely-krasovsky/immich that referenced this pull request Jun 8, 2025
* feat: private view

* pr feedback

* sql generation

* feat: visibility column

* fix: set visibility value as the same as the still part after unlinked live photos

* fix: test

* pr 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.

4 participants