From f2f6899d533ed87e1e11a6632b61388db39bdc6f Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 24 Nov 2023 14:01:17 -0800 Subject: [PATCH] dav: improve de-duplication for extend Signed-off-by: Varun Patil --- src/services/dav/base.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/services/dav/base.ts b/src/services/dav/base.ts index fdfa23f7..6bcc28db 100644 --- a/src/services/dav/base.ts +++ b/src/services/dav/base.ts @@ -194,10 +194,14 @@ export async function extendWithStack(photos: IPhoto[]) { } // Add stacked RAW files (deduped) - const stackRaw = Array.from(new Set(photos.map((p) => p.stackraw ?? []).flat())); + const stackRaw = photos.map((p) => p.stackraw ?? []).flat(); - // Combine and return - return photos.concat(livePhotos, stackRaw); + // Combine all files + const combined = photos.concat(livePhotos, stackRaw); + + // De-duplicate + const unique = new Map(combined.map((p) => [p.fileid, p])); + return Array.from(unique.values()); } /**