Store lists as Sets

This commit is contained in:
Sam Carlton 2021-01-22 23:14:44 -06:00
parent c7d39dd9f2
commit 1f5f47eab4
10 changed files with 30 additions and 38 deletions

View file

@ -21,7 +21,7 @@ export function appsRelatedToVideo ( video, allVideoAppsList ) {
return relatedApps
}
export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
export function videosRelatedToVideo ( video, allVideoAppsList, videoListSet ) {
const relatedVideos = {}
// console.log('videoList', videoList[0])
@ -30,7 +30,7 @@ export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
const featuredApps = appsRelatedToVideo( video, allVideoAppsList )
// Find other videos that also feature this video's app
for (const otherVideo of videoList) {
for (const otherVideo of videoListSet) {
for (const app of featuredApps) {
// console.log('otherVideo', otherVideo)
// Skip if this app is not in the other video's apps
@ -48,12 +48,14 @@ export function videosRelatedToVideo ( video, allVideoAppsList, videoList ) {
}
export function videosRelatedToApp ( app, videoList ) {
export function videosRelatedToApp ( app, videoListSet ) {
// console.log('videoListSet', videoListSet)
const relatedVideos = {}
// Find other videos that also feature this video's app
for (const video of videoList) {
for (const video of videoListSet) {
if (!video.apps.includes(app.slug)) continue
relatedVideos[video.id] = video