Skip to content

Commit

Permalink
feat(server, web): Include partner's photos on map (#7065)
Browse files Browse the repository at this point in the history
* feat(server): Include partner's photos on map - if included in timeline

* depend on query parameter withPartners

instead of partners.inTimeline

* web: map option to include partners images

* make open-api
  • Loading branch information
ttyridal committed Feb 14, 2024
1 parent 7d59900 commit 6adff50
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 19 deletions.
6 changes: 4 additions & 2 deletions mobile/openapi/doc/AssetApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions mobile/openapi/lib/api/asset_api.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mobile/openapi/test/asset_api_test.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,14 @@
"schema": {
"type": "boolean"
}
},
{
"name": "withPartners",
"required": false,
"in": "query",
"schema": {
"type": "boolean"
}
}
],
"responses": {
Expand Down
23 changes: 18 additions & 5 deletions open-api/typescript-sdk/axios-client/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions open-api/typescript-sdk/fetch-client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/src/domain/asset/asset.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ describe(AssetService.name, () => {

describe('getMapMarkers', () => {
it('should get geo information of assets', async () => {
partnerMock.getAll.mockResolvedValue([]);
assetMock.getMapMarkers.mockResolvedValue(
[assetStub.withLocation].map((asset) => ({
id: asset.id,
Expand Down
12 changes: 10 additions & 2 deletions server/src/domain/asset/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,16 @@ export class AssetService {
return folder;
}

getMapMarkers(auth: AuthDto, options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
return this.assetRepository.getMapMarkers(auth.user.id, options);
async getMapMarkers(auth: AuthDto, options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
const userIds: string[] = [auth.user.id];
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);
}

async getMemoryLane(auth: AuthDto, dto: MemoryLaneDto): Promise<MemoryLaneResponseDto[]> {
Expand Down
6 changes: 6 additions & 0 deletions server/src/domain/asset/dto/map-marker.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ export class MapMarkerDto {
@IsDate()
@Type(() => Date)
fileCreatedBefore?: Date;

@ApiProperty()
@Optional()
@IsBoolean()
@Transform(toBoolean)
withPartners?: boolean;
}
2 changes: 1 addition & 1 deletion server/src/domain/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface IAssetRepository {
softDeleteAll(ids: string[]): Promise<void>;
restoreAll(ids: string[]): Promise<void>;
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null>;
getMapMarkers(ownerId: string, options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
getMapMarkers(ownerIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
getStatistics(ownerId: string, options: AssetStatsOptions): Promise<AssetStats>;
getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]>;
getTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]>;
Expand Down
4 changes: 2 additions & 2 deletions server/src/infra/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class AssetRepository implements IAssetRepository {
});
}

async getMapMarkers(ownerId: string, options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> {
async getMapMarkers(ownerIds: string[], options: MapMarkerSearchOptions = {}): Promise<MapMarker[]> {
const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options;

const assets = await this.repository.find({
Expand All @@ -484,7 +484,7 @@ export class AssetRepository implements IAssetRepository {
},
},
where: {
ownerId,
ownerId: In([...ownerIds]),
isVisible: true,
isArchived,
exifInfo: {
Expand Down
1 change: 1 addition & 0 deletions web/src/lib/components/map-page/map-settings-modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<SettingSwitch title="Allow dark mode" bind:checked={settings.allowDarkMode} />
<SettingSwitch title="Only favorites" bind:checked={settings.onlyFavorites} />
<SettingSwitch title="Include archived" bind:checked={settings.includeArchived} />
<SettingSwitch title="Include shared with me" bind:checked={settings.withPartners} />
{#if customDateRange}
<div in:fly={{ y: 10, duration: 200 }} class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-8">
Expand Down
2 changes: 2 additions & 0 deletions web/src/lib/stores/preferences.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface MapSettings {
allowDarkMode: boolean;
includeArchived: boolean;
onlyFavorites: boolean;
withPartners: boolean;
relativeDate: string;
dateAfter: string;
dateBefore: string;
Expand All @@ -55,6 +56,7 @@ export const mapSettings = persisted<MapSettings>('map-settings', {
allowDarkMode: true,
includeArchived: false,
onlyFavorites: false,
withPartners: false,
relativeDate: '',
dateAfter: '',
dateBefore: '',
Expand Down
3 changes: 2 additions & 1 deletion web/src/routes/(user)/map/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
abortController = new AbortController();
const { includeArchived, onlyFavorites } = $mapSettings;
const { includeArchived, onlyFavorites, withPartners } = $mapSettings;
const { fileCreatedAfter, fileCreatedBefore } = getFileCreatedDates();
return await getMapMarkers(
Expand All @@ -55,6 +55,7 @@
isFavorite: onlyFavorites || undefined,
fileCreatedAfter: fileCreatedAfter || undefined,
fileCreatedBefore,
withPartners: withPartners || undefined,
},
{
signal: abortController.signal,
Expand Down

0 comments on commit 6adff50

Please sign in to comment.