1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

feat: use dateTimeOriginal to calculate album date (#14119)

This commit is contained in:
Pablo Molina 2024-11-13 18:17:14 +01:00 committed by GitHub
parent 3dad19883d
commit 333ca8827e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import { AuthDto } from 'src/dtos/auth.dto';
import { UserResponseDto, mapUser } from 'src/dtos/user.dto'; import { UserResponseDto, mapUser } from 'src/dtos/user.dto';
import { AlbumEntity } from 'src/entities/album.entity'; import { AlbumEntity } from 'src/entities/album.entity';
import { AlbumUserRole, AssetOrder } from 'src/enum'; import { AlbumUserRole, AssetOrder } from 'src/enum';
import { getAssetDateTime } from 'src/utils/date-time';
import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation'; import { Optional, ValidateBoolean, ValidateUUID } from 'src/validation';
export class AlbumInfoDto { export class AlbumInfoDto {
@ -164,8 +165,8 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt
const hasSharedLink = entity.sharedLinks?.length > 0; const hasSharedLink = entity.sharedLinks?.length > 0;
const hasSharedUser = sharedUsers.length > 0; const hasSharedUser = sharedUsers.length > 0;
let startDate = assets.at(0)?.fileCreatedAt || undefined; let startDate = getAssetDateTime(assets.at(0));
let endDate = assets.at(-1)?.fileCreatedAt || undefined; let endDate = getAssetDateTime(assets.at(-1));
// Swap dates if start date is greater than end date. // Swap dates if start date is greater than end date.
if (startDate && endDate && startDate > endDate) { if (startDate && endDate && startDate > endDate) {
[startDate, endDate] = [endDate, startDate]; [startDate, endDate] = [endDate, startDate];

View File

@ -0,0 +1,5 @@
import { AssetEntity } from 'src/entities/asset.entity';
export const getAssetDateTime = (asset: AssetEntity | undefined) => {
return asset?.exifInfo?.dateTimeOriginal || asset?.fileCreatedAt;
};