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): include pictures of shared albums on map #7439

Merged
merged 11 commits into from
May 13, 2024

Conversation

andreasgerstmayr
Copy link
Contributor

This PR adds a new setting "Include shared albums" to the map settings, to includes pictures of albums shared with the current user on the map.

Related: #3176

exifInfo: {
latitude: Not(IsNull()),
longitude: Not(IsNull()),
where: [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to write this OR expression?
WHERE (ownerID IN ... OR albumId IN ...) AND isVisible = ... AND isArchived = ... AND ...

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.

This looks really good. Thanks!

if (options.withPartners) {
const partners = await this.partnerRepository.getAll(auth.user.id);
const partnersIds = partners
.filter((partner) => partner.sharedBy && partner.sharedWith && partner.sharedById != auth.user.id)
.map((partner) => partner.sharedById);
userIds.push(...partnersIds);
}
return this.assetRepository.getMapMarkers(userIds, options);
if (options.withSharedAlbums) {
const sharedAlbums = await this.albumRepository.getShared(auth.user.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't include the asset relation does it?

Copy link
Contributor Author

@andreasgerstmayr andreasgerstmayr May 9, 2024

Choose a reason for hiding this comment

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

I don't understand, where should I include the asset relation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay so Jason answered me on Discord about this:
https://discord.com/channels/979116623879368755/994044917355663450/1238973376349864108

Jason said: "Just want to make sure this is not loading the album AND all the assets for it"

I said: "If I understand correctly, you are asking if it is loading only the shared albums when figuring out what to show on the map, versus loding the shared albums and all the assets. And the problem with that is loading all the assets in the shared album takes more resources."

Jason responded: "Yup"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this function does not query all assets, only the albums:

@GenerateSql({ params: [DummyValue.UUID] })
async getShared(ownerId: string): Promise<AlbumEntity[]> {
const albums = await this.repository.find({
relations: { albumUsers: { user: true }, sharedLinks: true, owner: true },
where: [
{ albumUsers: { userId: ownerId } },
{ sharedLinks: { userId: ownerId } },
{ ownerId, albumUsers: { user: Not(IsNull()) } },
],
order: { createdAt: 'DESC' },
});
return albums.map((album) => withoutDeletedUsers(album));

@@ -31,4 +31,10 @@ export class MapMarkerDto {
@IsBoolean()
@Transform(toBoolean)
withPartners?: boolean;

@ApiProperty()
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

The class got moved to server/src/dtos/search.dto.ts and doesn't have this annotation anymore.

Comment on lines 534 to 541
isVisible: true,
isArchived,
exifInfo: {
latitude: Not(IsNull()),
longitude: Not(IsNull()),
},
isFavorite,
fileCreatedAt: OptionalBetween(fileCreatedAfter, fileCreatedBefore),
Copy link
Contributor

Choose a reason for hiding this comment

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

This section is repeated twice. Can you move it up to a variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

Comment on lines 37 to 38
<SettingSwitch title="Include shared with me" bind:checked={settings.withPartners} />
<SettingSwitch title="Include shared albums" bind:checked={settings.withSharedAlbums} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remember this other option so it is more obvious what the difference is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed Include shared with me to Include shared from partners. Another option would be Include assets from partners.

What do you think, which option sounds better? Or do you have other suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not Jason but I would suggest Include partner assets or Include shared partner assets. Also, this rename is important for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it to Include shared partner assets now, thanks for the suggestion @NicholasFlamy

@jrasm91 jrasm91 self-assigned this Apr 29, 2024
@danieldietzler
Copy link
Member

@andreasgerstmayr You've requested a review from me but you haven't yet addressed @jrasm91 comments and there are also lots of merge conflicts right now...?

@andreasgerstmayr
Copy link
Contributor Author

@andreasgerstmayr You've requested a review from me but you haven't yet addressed @jrasm91 comments and there are also lots of merge conflicts right now...?

hi @danieldietzler, sorry about that, must have been some automated process (it's showing up as 2:35 in the night), maybe because you're listed as a codeowner. No idea why it's happening now and not when I created the PR though.

Sorry for the late response, I was on holiday for a couple of weeks and then didn't get time so far.
Thanks for the review, I'll rebase and implement the changes soon.

@danieldietzler
Copy link
Member

Ah ok got it. No rush then :)

@andreasgerstmayr
Copy link
Contributor Author

I fixed the merge conflicts and implemented (most of) @jrasm91 suggestions now (except the one I didn't understand, see above).
Sorry for the delay on my side!

Copy link
Contributor

@zackpollard zackpollard left a comment

Choose a reason for hiding this comment

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

LGTM, will let @jrasm91 take a look over it before we merge though

@zackpollard
Copy link
Contributor

I fixed a tsc error caused by changes in main since the branch was created as well as a prettier error in web. The PR should now be good to merge

@zackpollard zackpollard requested a review from jrasm91 May 13, 2024 10:59
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.

I updated this to include assets that are in shared albums where the user is the owner.

@jrasm91 jrasm91 merged commit 48927f5 into immich-app:main May 13, 2024
21 of 22 checks passed
@andreasgerstmayr
Copy link
Contributor Author

I updated this to include assets that are in shared albums where the user is the owner.

Good catch! I didn't think of that.

Thank you for merging! :)

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.

6 participants