diff --git a/web/src/lib/stores/assets-store.spec.ts b/web/src/lib/stores/assets-store.spec.ts index 05e31bc61a..7864c9618b 100644 --- a/web/src/lib/stores/assets-store.spec.ts +++ b/web/src/lib/stores/assets-store.spec.ts @@ -1,6 +1,6 @@ import { sdkMock } from '$lib/__mocks__/sdk.mock'; import { AbortError } from '$lib/utils'; -import { type AssetResponseDto, type TimeBucketResponseDto } from '@immich/sdk'; +import { type AssetResponseDto, type TimeBucketAssetResponseDto } from '@immich/sdk'; import { timelineAssetFactory, toResponseDto } from '@test-data/factories/asset-factory'; import { AssetStore, type TimelineAsset } from './assets-store.svelte'; @@ -23,7 +23,7 @@ describe('AssetStore', () => { .map((asset) => ({ ...asset, localDateTime: '2024-01-01T00:00:00.000Z' })), }; - const bucketAssetsResponse: Record = Object.fromEntries( + const bucketAssetsResponse: Record = Object.fromEntries( Object.entries(bucketAssets).map(([key, assets]) => [key, toResponseDto(...assets)]), ); @@ -75,7 +75,7 @@ describe('AssetStore', () => { .buildList(3) .map((asset) => ({ ...asset, localDateTime: '2024-01-01T00:00:00.000Z' })), }; - const bucketAssetsResponse: Record = Object.fromEntries( + const bucketAssetsResponse: Record = Object.fromEntries( Object.entries(bucketAssets).map(([key, assets]) => [key, toResponseDto(...assets)]), ); beforeEach(async () => { @@ -362,7 +362,7 @@ describe('AssetStore', () => { .buildList(3) .map((asset) => ({ ...asset, localDateTime: '2024-01-01T00:00:00.000Z' })), }; - const bucketAssetsResponse: Record = Object.fromEntries( + const bucketAssetsResponse: Record = Object.fromEntries( Object.entries(bucketAssets).map(([key, assets]) => [key, toResponseDto(...assets)]), ); diff --git a/web/src/lib/utils/thumbnail-util.ts b/web/src/lib/utils/thumbnail-util.ts index b37918cad2..f6e00a9a8d 100644 --- a/web/src/lib/utils/thumbnail-util.ts +++ b/web/src/lib/utils/thumbnail-util.ts @@ -41,19 +41,18 @@ export function getThumbnailSize(assetCount: number, viewWidth: number): number export const getAltText = derived(t, ($t) => { return (asset: TimelineAsset) => { const date = fromLocalDateTime(asset.localDateTime).toLocaleString({ dateStyle: 'long' }, { locale: get(locale) }); - const { city, country, people: names } = asset.description; - const hasPlace = city && country; + const hasPlace = asset.city && asset.country; - const peopleCount = names.length; + const peopleCount = asset.people.length; const isVideo = asset.isVideo; const values = { date, - city, - country, - person1: names[0], - person2: names[1], - person3: names[2], + city: asset.city, + country: asset.country, + person1: peopleCount > 0 ? asset.people[0] : undefined, + person2: peopleCount > 1 ? asset.people[1] : undefined, + person3: peopleCount > 2 ? asset.people[2] : undefined, isVideo, additionalCount: peopleCount > 3 ? peopleCount - 2 : 0, }; diff --git a/web/src/lib/utils/timeline-util.ts b/web/src/lib/utils/timeline-util.ts index 36b52c388e..1c9110b14c 100644 --- a/web/src/lib/utils/timeline-util.ts +++ b/web/src/lib/utils/timeline-util.ts @@ -72,11 +72,6 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset): const country = assetResponse.exifInfo?.country; const people = assetResponse.people?.map((person) => person.name) || []; - const description = { - city: city || null, - country: country || null, - people, - }; return { id: assetResponse.id, ownerId: assetResponse.ownerId, @@ -92,7 +87,9 @@ export const toTimelineAsset = (unknownAsset: AssetResponseDto | TimelineAsset): duration: assetResponse.duration || null, projectionType: assetResponse.exifInfo?.projectionType || null, livePhotoVideoId: assetResponse.livePhotoVideoId || null, - description, + city: city || null, + country: country || null, + people, }; }; export const isTimelineAsset = (arg: AssetResponseDto | TimelineAsset): arg is TimelineAsset => diff --git a/web/src/test-data/factories/asset-factory.ts b/web/src/test-data/factories/asset-factory.ts index 3d92c12bc3..efe3e6273b 100644 --- a/web/src/test-data/factories/asset-factory.ts +++ b/web/src/test-data/factories/asset-factory.ts @@ -1,12 +1,6 @@ import type { TimelineAsset } from '$lib/stores/assets-store.svelte'; import { faker } from '@faker-js/faker'; -import { - AssetTypeEnum, - type AssetResponseDto, - type TimeBucketAssetResponseDto, - type TimeBucketResponseDto, - type TimelineStackResponseDto, -} from '@immich/sdk'; +import { AssetTypeEnum, type AssetResponseDto, type TimeBucketAssetResponseDto } from '@immich/sdk'; import { Sync } from 'factory.ts'; export const assetFactory = Sync.makeFactory({ @@ -48,23 +42,21 @@ export const timelineAssetFactory = Sync.makeFactory({ stack: null, projectionType: null, livePhotoVideoId: Sync.each(() => faker.string.uuid()), - description: Sync.each(() => ({ - city: faker.location.city(), - country: faker.location.country(), - people: [faker.person.fullName()], - })), + city: faker.location.city(), + country: faker.location.country(), + people: [faker.person.fullName()], }); export const toResponseDto = (...timelineAsset: TimelineAsset[]) => { const bucketAssets: TimeBucketAssetResponseDto = { - description: [], + city: [], + country: [], duration: [], id: [], isArchived: [], isFavorite: [], isImage: [], isTrashed: [], - isVideo: [], livePhotoVideoId: [], localDateTime: [], ownerId: [], @@ -74,25 +66,22 @@ export const toResponseDto = (...timelineAsset: TimelineAsset[]) => { thumbhash: [], }; for (const asset of timelineAsset) { - bucketAssets.description.push(asset.description); + bucketAssets.city.push(asset.city); + bucketAssets.country.push(asset.country); bucketAssets.duration.push(asset.duration!); bucketAssets.id.push(asset.id); bucketAssets.isArchived.push(asset.isArchived ? 1 : 0); bucketAssets.isFavorite.push(asset.isFavorite ? 1 : 0); bucketAssets.isImage.push(asset.isImage ? 1 : 0); bucketAssets.isTrashed.push(asset.isTrashed ? 1 : 0); - bucketAssets.isVideo.push(asset.isVideo ? 1 : 0); bucketAssets.livePhotoVideoId.push(asset.livePhotoVideoId!); bucketAssets.localDateTime.push(asset.localDateTime); bucketAssets.ownerId.push(asset.ownerId); bucketAssets.projectionType.push(asset.projectionType!); bucketAssets.ratio.push(asset.ratio); - bucketAssets.stack.push(asset.stack as TimelineStackResponseDto); + bucketAssets.stack?.push(asset.stack ? [asset.stack.id, asset.stack.assetCount] : null); bucketAssets.thumbhash.push(asset.thumbhash!); } - const response: TimeBucketResponseDto = { - bucketAssets, - hasNextPage: false, - }; - return response; + + return bucketAssets; };