fix: only add kept assets to albums they're not already in

When multiple assets are kept, each is now only added to albums it's
missing from, rather than adding all kept assets to every transferred
album.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ben BrooksandClaude Opus 4.6 committed 2026-02-28 23:27:51 +00:00
1 parent 8b394a253a
commit b90917ac20
1 file changed
+13 -4
+13 -4
View File
@@ -322,10 +322,19 @@ export default function BulkDuplicatePage() {
) => {
setIsDeleting(true);
try {
// Move albums to kept assets
await Promise.all(
albumIdsToTransfer.map(albumId => addAssetToAlbum(albumId, keptIds))
);
// Move albums to kept assets (only add each asset to albums it's not already in)
const transferCalls: Promise<unknown>[] = [];
const albumIdsToTransferSet = new Set(albumIdsToTransfer);
for (const albumId of albumIdsToTransferSet) {
const assetsToAdd = keptIds.filter(id => {
const existing = assetAlbums[id] || [];
return !existing.some(a => a.albumId === albumId);
});
if (assetsToAdd.length > 0) {
transferCalls.push(addAssetToAlbum(albumId, assetsToAdd));
}
}
await Promise.all(transferCalls);
// Mark kept assets as non-duplicate
if (keptIds.length > 0) {