From 3cce43309cb0d6bbc5d0b5f2a9bb53f59a4e1107 Mon Sep 17 00:00:00 2001 From: Fynn Petersen-Frey Date: Sat, 11 Mar 2023 13:41:46 +0100 Subject: [PATCH] fix(server): update album updatedAt on assets/users removed/added (#1977) --- .../immich/src/api-v1/album/album-repository.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/apps/immich/src/api-v1/album/album-repository.ts b/server/apps/immich/src/api-v1/album/album-repository.ts index 1fbf9279bc..bdeaa4b3ce 100644 --- a/server/apps/immich/src/api-v1/album/album-repository.ts +++ b/server/apps/immich/src/api-v1/album/album-repository.ts @@ -155,6 +155,7 @@ export class AlbumRepository implements IAlbumRepository { async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise { album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity))); + album.updatedAt = new Date().toISOString(); await this.albumRepository.save(album); @@ -164,6 +165,7 @@ export class AlbumRepository implements IAlbumRepository { async removeUser(album: AlbumEntity, userId: string): Promise { album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId); + album.updatedAt = new Date().toISOString(); await this.albumRepository.save(album); } @@ -174,9 +176,13 @@ export class AlbumRepository implements IAlbumRepository { return !removeAssetsDto.assetIds.includes(asset.id); }); + const numRemovedAssets = assetCount - album.assets.length; + if (numRemovedAssets > 0) { + album.updatedAt = new Date().toISOString(); + } await this.albumRepository.save(album, {}); - return assetCount - album.assets.length; + return numRemovedAssets; } async addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise { @@ -197,10 +203,14 @@ export class AlbumRepository implements IAlbumRepository { album.albumThumbnailAssetId = album.assets[0].id; } + const successfullyAdded = addAssetsDto.assetIds.length - alreadyExisting.length; + if (successfullyAdded > 0) { + album.updatedAt = new Date().toISOString(); + } await this.albumRepository.save(album); return { - successfullyAdded: addAssetsDto.assetIds.length - alreadyExisting.length, + successfullyAdded, alreadyInAlbum: alreadyExisting, }; }