1
0
mirror of https://github.com/immich-app/immich.git synced 2025-01-12 15:32:36 +02:00

fix(server): remove albumThumbnailAssetId when album is empty (#495)

This commit is contained in:
Thanh Pham 2022-08-20 01:47:14 +07:00 committed by GitHub
parent 25338ce02f
commit 0cf7606ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<AlbumEntity>;
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');
}