From cca28b782d46f034d59c09549a5c03fee2566944 Mon Sep 17 00:00:00 2001 From: harika kondur Date: Fri, 12 Jun 2026 12:47:09 -0600 Subject: [PATCH] fix(wistia-videos): deduplicate videos to prevent double entries in field [ES-372] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a Wistia account has more than 500 videos in a single project, the pagination logic fetches additional pages — but Wistia ignores the page param on the project endpoint and returns all medias on every page. This causes each video to appear twice in the data array, and since setNewValues filters by ID, both copies get written to the field value. Fix by deduplicating by video ID after flattening the results in fetchVideos. Co-Authored-By: Claude Sonnet 4.6 --- apps/wistia-videos/src/functions/getVideos.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/wistia-videos/src/functions/getVideos.ts b/apps/wistia-videos/src/functions/getVideos.ts index 90ebb12ec8..06155acc12 100644 --- a/apps/wistia-videos/src/functions/getVideos.ts +++ b/apps/wistia-videos/src/functions/getVideos.ts @@ -93,5 +93,12 @@ export const fetchVideos = async ( ); // Flatten array of arrays const videos = mappedProjects.flat(1); - return videos; + // Deduplicate by video ID — pagination fetches can return the same video twice + // when Wistia ignores the page param and returns all medias on every page + const seen = new Set(); + return videos.filter((v) => { + if (seen.has(v.id)) return false; + seen.add(v.id); + return true; + }); };