« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--upd8-util.js2
-rwxr-xr-xupd8.js11
2 files changed, 8 insertions, 5 deletions
diff --git a/upd8-util.js b/upd8-util.js
index a266efbd..b18c0529 100644
--- a/upd8-util.js
+++ b/upd8-util.js
@@ -304,3 +304,5 @@ module.exports.curry = f => x => (...args) => f(x, ...args);
 module.exports.mapInPlace = (array, fn) => array.splice(0, array.length, ...array.map(fn));
 
 module.exports.filterEmptyLines = string => string.split('\n').filter(line => line.trim()).join('\n');
+
+module.exports.unique = arr => Array.from(new Set(arr));
diff --git a/upd8.js b/upd8.js
index 11c8ad0e..130f6067 100755
--- a/upd8.js
+++ b/upd8.js
@@ -114,7 +114,8 @@ const {
     queue,
     s,
     splitArray,
-    th
+    th,
+    unique
 } = require('./upd8-util');
 
 const C = require('./common/common');
@@ -2311,18 +2312,18 @@ async function writeArtistPage(artist) {
         note = ''
     } = artist;
 
-    const artThingsAll = C.sortByDate(Array.from(new Set([...artist.tracks.asCoverArtist, ...artist.albums.asCoverArtist, ...artist.albums.asWallpaperArtist])));
+    const artThingsAll = C.sortByDate(unique([...artist.tracks.asCoverArtist, ...artist.albums.asCoverArtist, ...artist.albums.asWallpaperArtist]));
     const artThingsGallery = C.sortByDate([...artist.albums.asCoverArtist, ...artist.tracks.asCoverArtist]);
-    const commentaryThings = C.sortByDate([...artist.tracks.asCommentator, ...artist.albums.asCommentator]);
+    const commentaryThings = C.sortByDate([...artist.albums.asCommentator, ...artist.tracks.asCommentator]);
 
     let flashes;
     if (wikiInfo.features.flashesAndGames) {
         flashes = artist.flashes.asContributor;
     }
 
-    const unreleasedTracks = [...artist.tracks.asArtist, ...artist.tracks.asContributor]
+    const unreleasedTracks = unique([...artist.tracks.asArtist, ...artist.tracks.asContributor])
         .filter(track => track.album.directory === C.UNRELEASED_TRACKS_DIRECTORY);
-    const releasedTracks = [...artist.tracks.asArtist, ...artist.tracks.asContributor]
+    const releasedTracks = unique([...artist.tracks.asArtist, ...artist.tracks.asContributor])
         .filter(track => track.album.directory !== C.UNRELEASED_TRACKS_DIRECTORY);
 
     const generateTrackList = tracks => albumChunkedList(tracks, (track, i) => {