From 0cf7606ec96bb5007001d06c3cf46c53ecf0b98e Mon Sep 17 00:00:00 2001 From: Thanh Pham Date: Sat, 20 Aug 2022 01:47:14 +0700 Subject: [PATCH] fix(server): remove albumThumbnailAssetId when album is empty (#495) --- server/apps/immich/src/api-v1/album/album-repository.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 11ea08f7e9..7581620d28 100644 --- a/server/apps/immich/src/api-v1/album/album-repository.ts +++ b/server/apps/immich/src/api-v1/album/album-repository.ts @@ -202,7 +202,14 @@ export class AlbumRepository implements IAlbumRepository { // TODO: No need to return boolean if using a singe delete query if (deleteAssetCount == removeAssetsDto.assetIds.length) { - return this.get(album.id) as Promise; + const retAlbum = await this.get(album.id) as AlbumEntity; + + if (retAlbum?.assets?.length === 0) { // is empty album + await this.albumRepository.update(album.id, { albumThumbnailAssetId: null }); + retAlbum.albumThumbnailAssetId = null; + } + + return retAlbum; } else { throw new BadRequestException('Some assets were not found in the album'); }