« get me outta code hell

scratchrlol - Simple HTML-based Scratch client
summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xindex.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/index.js b/index.js
index 24e8454..27552c9 100755
--- a/index.js
+++ b/index.js
@@ -317,8 +317,14 @@ const explore = {
     }
 
     const fetchResults = await Promise.all(['recent', 'trending', 'popular'].map(m => fetch(getUrl(m)).then(res => res.json())))
-    console.log(fetchResults)
     const projects = fetchResults.reduce((acc, arr) => acc.concat(arr), [])
+
+    // Dumb "remove duplicates" code incoming!
+    let authors = projects.map(project => project.author)
+    const seenUsernames = []
+    authors = authors.filter(
+      ({ username: un }) => seenUsernames.includes(un) ? false : (seenUsernames.push(un), true))
+
     const selected = shuffle(projects).slice(0, 15)
     return selected.map(project => project.author)
   }