Fix duplicate related video entries

This commit is contained in:
Sam Carlton 2020-12-26 19:18:57 -06:00
parent afec75f482
commit d8f0c8b486

View file

@ -21,7 +21,7 @@ export function appsRelatedToVideo ( video ) {
} }
export function videosRelatedToVideo ( video ) { export function videosRelatedToVideo ( video ) {
const relatedVideos = [] const relatedVideos = {}
const featuredApps = appsRelatedToVideo( video ) const featuredApps = appsRelatedToVideo( video )
@ -35,23 +35,23 @@ export function videosRelatedToVideo ( video ) {
if (otherVideo.slug === video.slug) continue if (otherVideo.slug === video.slug) continue
// Add this video to our related videos list // 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 ) { export function videosRelatedToApp ( app ) {
const relatedVideos = [] const relatedVideos = {}
// Find other videos that also feature this video's app // Find other videos that also feature this video's app
for (const video of videoList) { for (const video of videoList) {
if (!video.apps.includes(app.slug)) continue if (!video.apps.includes(app.slug)) continue
relatedVideos.push(video) relatedVideos[video.id] = video
} }
return relatedVideos return Object.values(relatedVideos)
} }