From 9e4ed2214bcc95d72e1ea79f5bbda37c3c9beeae Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 11 Sep 2022 10:07:04 -0500 Subject: [PATCH] fix(web): incorrect shared album count (#677) --- server/apps/immich/src/api-v1/album/album-repository.ts | 9 +++++++-- 1 file changed, 7 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 5b8aaad0c1..e5c1c4bc7f 100644 --- a/server/apps/immich/src/api-v1/album/album-repository.ts +++ b/server/apps/immich/src/api-v1/album/album-repository.ts @@ -50,9 +50,14 @@ export class AlbumRepository implements IAlbumRepository { where: { sharedUserId: userId }, }); - const sharingAlbums = ownedAlbums.map((album) => album.sharedUsers?.length || 0).reduce((a, b) => a + b, 0); + let sharedAlbumCount = 0; + ownedAlbums.map((album) => { + if (album.sharedUsers?.length) { + sharedAlbumCount += 1; + } + }); - return new AlbumCountResponseDto(ownedAlbums.length, sharedAlbums, sharingAlbums); + return new AlbumCountResponseDto(ownedAlbums.length, sharedAlbums, sharedAlbumCount); } async create(ownerId: string, createAlbumDto: CreateAlbumDto): Promise {