« get me outta code hell

data: isolate withResolvedContribs internal behavior - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/thing.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-06 14:34:12 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-06 14:34:12 -0300
commit6f242fc864028a12321255ba04a88c6190801510 (patch)
treed3b78278ed4e16578f2e298f276a9297ae3e42e4 /src/data/things/thing.js
parent703f065560e71ec7f750ea8a9dfdff2c71e0fde8 (diff)
data: isolate withResolvedContribs internal behavior
Diffstat (limited to 'src/data/things/thing.js')
-rw-r--r--src/data/things/thing.js30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 01aa8b1b..9bfed080 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -249,14 +249,16 @@ export default class Thing extends CacheableObject {
     // filtered out. (So if the list is all empty, chances are that either the
     // reference list is somehow messed up, or artistData isn't being provided
     // properly.)
-    dynamicContribs: (contribsByRefProperty) => ({
-      flags: {expose: true},
-      expose: {
-        dependencies: ['artistData', contribsByRefProperty],
-        compute: ({artistData, [contribsByRefProperty]: contribsByRef}) =>
-          Thing.findArtistsFromContribs(contribsByRef, artistData),
-      },
-    }),
+    dynamicContribs(contribsByRefProperty) {
+      return Thing.composite.from(`Thing.common.dynamicContribs`, [
+        Thing.composite.withResolvedContribs({
+          from: contribsByRefProperty,
+          to: '#contribs',
+        }),
+
+        Thing.composite.exposeDependency('#contribs'),
+      ]);
+    },
 
     // Nice 'n simple shorthand for an exposed-only flag which is true when any
     // contributions are present in the specified property.
@@ -348,17 +350,5 @@ export default class Thing extends CacheableObject {
     return `${thing.constructor[Thing.referenceType]}:${thing.directory}`;
   }
 
-  static findArtistsFromContribs(contribsByRef, artistData) {
-    if (empty(contribsByRef)) return null;
-
-    return (
-      contribsByRef
-        .map(({who, what}) => ({
-          who: find.artist(who, artistData, {mode: 'quiet'}),
-          what,
-        }))
-        .filter(({who}) => who));
-  }
-
   static composite = composite;
 }