From d8f0c8b486f392cdf6aa125c975d9422a729bc5c Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 26 Dec 2020 19:18:57 -0600 Subject: [PATCH] Fix duplicate related video entries --- helpers/related.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helpers/related.js b/helpers/related.js index 324541d..c22a510 100644 --- a/helpers/related.js +++ b/helpers/related.js @@ -21,7 +21,7 @@ export function appsRelatedToVideo ( video ) { } export function videosRelatedToVideo ( video ) { - const relatedVideos = [] + const relatedVideos = {} const featuredApps = appsRelatedToVideo( video ) @@ -35,23 +35,23 @@ export function videosRelatedToVideo ( video ) { if (otherVideo.slug === video.slug) continue // Add this video to our related videos list - relatedVideos.push(otherVideo) + relatedVideos[otherVideo.id] = otherVideo } } - return relatedVideos + return Object.values(relatedVideos) } export function videosRelatedToApp ( app ) { - const relatedVideos = [] + const relatedVideos = {} // Find other videos that also feature this video's app for (const video of videoList) { if (!video.apps.includes(app.slug)) continue - relatedVideos.push(video) + relatedVideos[video.id] = video } - return relatedVideos + return Object.values(relatedVideos) }