diff --git a/server/src/services/album.service.ts b/server/src/services/album.service.ts index d456522021..dd12e31892 100644 --- a/server/src/services/album.service.ts +++ b/server/src/services/album.service.ts @@ -79,7 +79,6 @@ export class AlbumService extends BaseService { const album = await this.findOrFail(id, { withAssets }); const [albumMetadataForIds] = await this.albumRepository.getMetadataForIds([album.id]); - // Determine if the album is shared (shared users or shared link) const hasSharedUsers = album.albumUsers && album.albumUsers.length > 0; const hasSharedLink = album.sharedLinks && album.sharedLinks.length > 0; const isShared = hasSharedUsers || hasSharedLink; @@ -90,7 +89,6 @@ export class AlbumService extends BaseService { endDate: albumMetadataForIds?.endDate ?? undefined, assetCount: albumMetadataForIds?.assetCount ?? 0, lastModifiedAssetTimestamp: albumMetadataForIds?.lastModifiedAssetTimestamp ?? undefined, - // Fetch contributor counts only for shared albums contributorCounts: isShared ? await this.albumRepository.getContributorCounts(album.id) : undefined, }; } diff --git a/web/src/lib/modals/AlbumUsersModal.svelte b/web/src/lib/modals/AlbumUsersModal.svelte index d87f9ee52d..7dd7442249 100644 --- a/web/src/lib/modals/AlbumUsersModal.svelte +++ b/web/src/lib/modals/AlbumUsersModal.svelte @@ -32,10 +32,12 @@ let isOwned = $derived(currentUser?.id == album.ownerId); // Build a map of contributor counts by user id; avoid casts/derived - const contributorMap: Record = Object.fromEntries( - (album.contributorCounts ?? []).map(({ userId, assetCount }) => [userId, assetCount]), - ); - const getCount = (userId: string) => contributorMap[userId] ?? 0; + const contributorCounts: Record = {}; + if (album.contributorCounts) { + for (const { userId, assetCount } of album.contributorCounts) { + contributorCounts[userId] = assetCount; + } + } onMount(async () => { try { @@ -117,9 +119,9 @@ {:else} {$t('role_editor')} {/if} - {#if getCount(user.id) > 0} + {#if user.id in contributorCounts} - - {$t('items_count', { values: { count: getCount(user.id) } })} + {$t('items_count', { values: { count: contributorCounts[user.id] } })} {/if}