update references to description

This commit is contained in:
mertalev
2025-05-05 09:12:07 -04:00
parent ef9245487c
commit 1d885c1a20
4 changed files with 25 additions and 40 deletions
+4 -4
View File
@@ -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<string, TimeBucketResponseDto> = Object.fromEntries(
const bucketAssetsResponse: Record<string, TimeBucketAssetResponseDto> = 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<string, TimeBucketResponseDto> = Object.fromEntries(
const bucketAssetsResponse: Record<string, TimeBucketAssetResponseDto> = 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<string, TimeBucketResponseDto> = Object.fromEntries(
const bucketAssetsResponse: Record<string, TimeBucketAssetResponseDto> = Object.fromEntries(
Object.entries(bucketAssets).map(([key, assets]) => [key, toResponseDto(...assets)]),
);
+7 -8
View File
@@ -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,
};
+3 -6
View File
@@ -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 =>