« 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--src/data/things/album.js17
-rw-r--r--src/data/things/composite.js6
-rw-r--r--src/data/things/thing.js4
-rw-r--r--src/data/things/track.js25
4 files changed, 35 insertions, 17 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 20a1a5b3..fd8a71d3 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -122,9 +122,20 @@ export class Album extends Thing {
         ]),
       }),
 
-      fillMissingListItems({list: '#sections.tracks', value: []}),
-      fillMissingListItems({list: '#sections.isDefaultTrackSection', value: false}),
-      fillMissingListItems({list: '#sections.color', dependency: 'color'}),
+      fillMissingListItems({
+        list: '#sections.tracks',
+        fill: input.value([]),
+      }),
+
+      fillMissingListItems({
+        list: '#sections.isDefaultTrackSection',
+        fill: input.value(false),
+      }),
+
+      fillMissingListItems({
+        list: '#sections.color',
+        fill: input.dependency('color'),
+      }),
 
       withFlattenedList({
         list: '#sections.tracks',
diff --git a/src/data/things/composite.js b/src/data/things/composite.js
index 40f4fc16..38b7bcc9 100644
--- a/src/data/things/composite.js
+++ b/src/data/things/composite.js
@@ -2073,7 +2073,7 @@ export const withFlattenedList = templateCompositeFrom({
         const flattenedList = sourceList.flat();
         const indices = [];
         let lastEndIndex = 0;
-        for (const {length} of sourceArray) {
+        for (const {length} of sourceList) {
           indices.push(lastEndIndex);
           lastEndIndex += length;
         }
@@ -2116,8 +2116,8 @@ export const withUnflattenedList = templateCompositeFrom({
 
   steps: () => [
     {
-      dependencies: [input('list'), input('indices')],
-      compute({
+      dependencies: [input('list'), input('indices'), input('filter')],
+      compute(continuation, {
         [input('list')]: list,
         [input('indices')]: indices,
         [input('filter')]: filter,
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index f63a619d..0dea1fa4 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -216,7 +216,7 @@ export function contributionList() {
     steps: [
       withResolvedContribs({from: input.updateValue()}),
       exposeDependencyOrContinue({dependency: '#resolvedContribs'}),
-      exposeConstant({value: []}),
+      exposeConstant({value: input.value([])}),
     ],
   });
 }
@@ -343,7 +343,7 @@ export const singleReference = templateCompositeFrom({
     withResolvedReference({
       ref: input.updateValue(),
       data: input('data'),
-      find: input('findFunction'),
+      find: input('find'),
     }),
 
     exposeDependency({dependency: '#resolvedReference'}),
diff --git a/src/data/things/track.js b/src/data/things/track.js
index f31fe3ae..5ccf4f8b 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -210,7 +210,10 @@ export class Track extends Thing {
     ],
 
     contributorContribs: [
-      inheritFromOriginalRelease({property: 'contributorContribs'}),
+      inheritFromOriginalRelease({
+        property: input.value('contributorContribs'),
+      }),
+
       contributionList(),
     ],
 
@@ -236,7 +239,9 @@ export class Track extends Thing {
     ],
 
     referencedTracks: [
-      inheritFromOriginalRelease({property: 'referencedTracks'}),
+      inheritFromOriginalRelease({
+        property: input.value('referencedTracks'),
+      }),
 
       referenceList({
         class: input.value(Track),
@@ -246,7 +251,9 @@ export class Track extends Thing {
     ],
 
     sampledTracks: [
-      inheritFromOriginalRelease({property: 'sampledTracks'}),
+      inheritFromOriginalRelease({
+        property: input.value('sampledTracks'),
+      }),
 
       referenceList({
         class: input.value(Track),
@@ -313,11 +320,11 @@ export class Track extends Thing {
       {
         flags: {expose: true},
         expose: {
-          dependencies: ['this', 'trackData', '#originalRelease'],
+          dependencies: [input.myself(), '#originalRelease', 'trackData'],
           compute: ({
-            this: thisTrack,
+            [input.myself()]: thisTrack,
+            ['#originalRelease']: originalRelease,
             trackData,
-            '#originalRelease': originalRelease,
           }) =>
             (originalRelease === thisTrack
               ? []
@@ -339,17 +346,17 @@ export class Track extends Thing {
     // the "Tracks - by Times Referenced" listing page (or other data
     // processing).
     referencedByTracks: trackReverseReferenceList({
-      list: 'referencedTracks',
+      list: input.value('referencedTracks'),
     }),
 
     // For the same reasoning, exclude re-releases from sampled tracks too.
     sampledByTracks: trackReverseReferenceList({
-      list: 'sampledTracks',
+      list: input.value('sampledTracks'),
     }),
 
     featuredInFlashes: reverseReferenceList({
       data: 'flashData',
-      list: 'featuredTracks',
+      list: input.value('featuredTracks'),
     }),
   });