« get me outta code hell

data: dynamicThingsFromReferenceList -> resolvedReferenceList - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-06 15:22:58 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-06 15:22:58 -0300
commit2d7c536ee91a8f5bf8f16db1fc2d0a4d8bb4fc85 (patch)
tree21cb39f3e65cd058259f8f9e3e4be8834ea93b76 /src
parent137bd813980d77441a86303ac6c04b61d9ccb8da (diff)
data: dynamicThingsFromReferenceList -> resolvedReferenceList
Diffstat (limited to 'src')
-rw-r--r--src/data/things/album.js13
-rw-r--r--src/data/things/composite.js12
-rw-r--r--src/data/things/flash.js16
-rw-r--r--src/data/things/group.js16
-rw-r--r--src/data/things/homepage-layout.js10
-rw-r--r--src/data/things/thing.js12
-rw-r--r--src/data/things/track.js18
-rw-r--r--src/data/things/wiki-info.js6
8 files changed, 68 insertions, 35 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 06982903..81f04f70 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -128,8 +128,17 @@ export class Album extends Thing {
 
     commentatorArtists: Thing.common.commentatorArtists(),
 
-    groups: Thing.common.dynamicThingsFromReferenceList('groupsByRef', 'groupData', find.group),
-    artTags: Thing.common.dynamicThingsFromReferenceList('artTagsByRef', 'artTagData', find.artTag),
+    groups: Thing.common.resolvedReferenceList({
+      list: 'groupsByRef',
+      data: 'groupData',
+      find: find.group,
+    }),
+
+    artTags: Thing.common.resolvedReferenceList({
+      list: 'artTagsByRef',
+      data: 'artTagData',
+      find: find.artTag,
+    }),
 
     hasCoverArt: Thing.common.contribsPresent('coverArtistContribsByRef'),
     hasWallpaperArt: Thing.common.contribsPresent('wallpaperArtistContribsByRef'),
diff --git a/src/data/things/composite.js b/src/data/things/composite.js
index e930e228..7f3463cf 100644
--- a/src/data/things/composite.js
+++ b/src/data/things/composite.js
@@ -1130,7 +1130,7 @@ export function withResolvedContribs({from, to}) {
     },
 
     withResolvedReferenceList({
-      refList: '#whoByRef',
+      list: '#whoByRef',
       data: 'artistData',
       to: '#who',
       find: find.artist,
@@ -1192,7 +1192,7 @@ export function withResolvedReference({
 // it will filter out references which don't match, but this can be changed
 // to early exit ({notFoundMode: 'exit'}) or leave null in place ('null').
 export function withResolvedReferenceList({
-  refList,
+  list,
   data,
   to,
   find: findFunction,
@@ -1205,7 +1205,7 @@ export function withResolvedReferenceList({
   return compositeFrom(`Thing.composite.withResolvedReferenceList`, [
     earlyExitWithoutDependency(data, {value: []}),
 
-    raiseWithoutDependency(refList, {
+    raiseWithoutDependency(list, {
       map: {to},
       raise: {to: []},
       mode: 'empty',
@@ -1213,12 +1213,12 @@ export function withResolvedReferenceList({
 
     {
       options: {findFunction, notFoundMode},
-      mapDependencies: {refList, data},
+      mapDependencies: {list, data},
       mapContinuation: {matches: to},
 
-      compute({refList, data, '#options': {findFunction, notFoundMode}}, continuation) {
+      compute({list, data, '#options': {findFunction, notFoundMode}}, continuation) {
         let matches =
-          refList.map(ref => findFunction(ref, data, {mode: 'quiet'}));
+          list.map(ref => findFunction(ref, data, {mode: 'quiet'}));
 
         if (!matches.includes(null)) {
           return continuation.raise({matches});
diff --git a/src/data/things/flash.js b/src/data/things/flash.js
index 3f870c51..baef23d8 100644
--- a/src/data/things/flash.js
+++ b/src/data/things/flash.js
@@ -67,11 +67,11 @@ export class Flash extends Thing {
 
     contributorContribs: Thing.common.dynamicContribs('contributorContribsByRef'),
 
-    featuredTracks: Thing.common.dynamicThingsFromReferenceList(
-      'featuredTracksByRef',
-      'trackData',
-      find.track
-    ),
+    featuredTracks: Thing.common.resolvedReferenceList({
+      list: 'featuredTracksByRef',
+      data: 'trackData',
+      find: find.track,
+    }),
 
     act: {
       flags: {expose: true},
@@ -141,6 +141,10 @@ export class FlashAct extends Thing {
 
     // Expose only
 
-    flashes: Thing.common.dynamicThingsFromReferenceList('flashesByRef', 'flashData', find.flash),
+    flashes: Thing.common.resolvedReferenceList({
+      list: 'flashesByRef',
+      data: 'flashData',
+      find: find.flash,
+    }),
   })
 }
diff --git a/src/data/things/group.js b/src/data/things/group.js
index f552b8f3..d04fcf56 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -26,7 +26,11 @@ export class Group extends Thing {
 
     // Expose only
 
-    featuredAlbums: Thing.common.dynamicThingsFromReferenceList('featuredAlbumsByRef', 'albumData', find.album),
+    featuredAlbums: Thing.common.resolvedReferenceList({
+      list: 'featuredAlbumsByRef',
+      data: 'albumData',
+      find: find.album,
+    }),
 
     descriptionShort: {
       flags: {expose: true},
@@ -88,10 +92,10 @@ export class GroupCategory extends Thing {
 
     // Expose only
 
-    groups: Thing.common.dynamicThingsFromReferenceList(
-      'groupsByRef',
-      'groupData',
-      find.group
-    ),
+    groups: Thing.common.resolvedReferenceList({
+      list: 'groupsByRef',
+      data: 'groupData',
+      find: find.group,
+    }),
   });
 }
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js
index ec9e9556..cbdcb99a 100644
--- a/src/data/things/homepage-layout.js
+++ b/src/data/things/homepage-layout.js
@@ -125,10 +125,10 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow {
       find.group
     ),
 
-    sourceAlbums: Thing.common.dynamicThingsFromReferenceList(
-      'sourceAlbumsByRef',
-      'albumData',
-      find.album
-    ),
+    sourceAlbums: Thing.common.resolvedReferenceList({
+      list: 'sourceAlbumsByRef',
+      data: 'albumData',
+      find: find.album,
+    }),
   });
 }
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 9f77c3fc..f36b08bc 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -193,14 +193,14 @@ export default class Thing extends CacheableObject {
     // Corresponding dynamic property to referenceList, which takes the values
     // in the provided property and searches the specified wiki data for
     // matching actual Thing-subclass objects.
-    dynamicThingsFromReferenceList(
-      refList,
+    resolvedReferenceList({
+      list,
       data,
-      findFunction
-    ) {
-      return Thing.composite.from(`Thing.common.dynamicThingsFromReferenceList`, [
+      find: findFunction,
+    }) {
+      return Thing.composite.from(`Thing.common.resolvedReferenceList`, [
         Thing.composite.withResolvedReferenceList({
-          refList,
+          list,
           data,
           to: '#things',
           find: findFunction,
diff --git a/src/data/things/track.js b/src/data/things/track.js
index bf56a6dd..733c81c9 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -250,15 +250,27 @@ export class Track extends Thing {
 
     referencedTracks: Thing.composite.from(`Track.referencedTracks`, [
       Track.composite.inheritFromOriginalRelease({property: 'referencedTracks'}),
-      Thing.common.dynamicThingsFromReferenceList('referencedTracksByRef', 'trackData', find.track),
+      Thing.common.resolvedReferenceList({
+        list: 'referencedTracksByRef',
+        data: 'trackData',
+        find: find.track,
+      }),
     ]),
 
     sampledTracks: Thing.composite.from(`Track.sampledTracks`, [
       Track.composite.inheritFromOriginalRelease({property: 'sampledTracks'}),
-      Thing.common.dynamicThingsFromReferenceList('sampledTracksByRef', 'trackData', find.track),
+      Thing.common.resolvedReferenceList({
+        list: 'sampledTracksByRef',
+        data: 'trackData',
+        find: find.track,
+      }),
     ]),
 
-    artTags: Thing.common.dynamicThingsFromReferenceList('artTagsByRef', 'artTagData', find.artTag),
+    artTags: Thing.common.resolvedReferenceList({
+      list: 'artTagsByRef',
+      data: 'artTagData',
+      find: find.artTag,
+    }),
 
     // Specifically exclude re-releases from this list - while it's useful to
     // get from a re-release to the tracks it references, re-releases aren't
diff --git a/src/data/things/wiki-info.js b/src/data/things/wiki-info.js
index e8279987..d6790c55 100644
--- a/src/data/things/wiki-info.js
+++ b/src/data/things/wiki-info.js
@@ -59,6 +59,10 @@ export class WikiInfo extends Thing {
 
     // Expose only
 
-    divideTrackListsByGroups: Thing.common.dynamicThingsFromReferenceList('divideTrackListsByGroupsByRef', 'groupData', find.group),
+    divideTrackListsByGroups: Thing.common.resolvedReferenceList({
+      list: 'divideTrackListsByGroupsByRef',
+      data: 'groupData',
+      find: find.group,
+    }),
   });
 }