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:
parent
3dad19883d
commit
333ca8827e
@ -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];
|
||||||
|
5
server/src/utils/date-time.ts
Normal file
5
server/src/utils/date-time.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { AssetEntity } from 'src/entities/asset.entity';
|
||||||
|
|
||||||
|
export const getAssetDateTime = (asset: AssetEntity | undefined) => {
|
||||||
|
return asset?.exifInfo?.dateTimeOriginal || asset?.fileCreatedAt;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user