« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/album.js6
-rw-r--r--src/data/things/thing.js15
2 files changed, 9 insertions, 12 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 01f52c2d..fb0c3427 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -194,9 +194,9 @@ export class Album extends Thing {
 
     commentatorArtists: commentatorArtists(),
 
-    hasCoverArt: contribsPresent('coverArtistContribs'),
-    hasWallpaperArt: contribsPresent('wallpaperArtistContribs'),
-    hasBannerArt: contribsPresent('bannerArtistContribs'),
+    hasCoverArt: contribsPresent({contribs: 'coverArtistContribs'}),
+    hasWallpaperArt: contribsPresent({contribs: 'wallpaperArtistContribs'}),
+    hasBannerArt: contribsPresent({contribs: 'bannerArtistContribs'}),
 
     tracks: compositeFrom(`Album.tracks`, [
       exitWithoutDependency({dependency: 'trackData', value: []}),
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 79d8ae0e..0f47dc90 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -15,6 +15,7 @@ import {
   exposeDependency,
   exposeDependencyOrContinue,
   raiseWithoutDependency,
+  withResultOfAvailabilityCheck,
   withUpdateValueAsDependency,
 } from '#composite';
 
@@ -297,15 +298,11 @@ export function singleReference({
 
 // Nice 'n simple shorthand for an exposed-only flag which is true when any
 // contributions are present in the specified property.
-export function contribsPresent(contribsProperty) {
-  return {
-    flags: {expose: true},
-    expose: {
-      dependencies: [contribsProperty],
-      compute: ({[contribsProperty]: contribs}) =>
-        !empty(contribs),
-    },
-  };
+export function contribsPresent({contribs}) {
+  return compositeFrom(`contribsPresent`, [
+    withResultOfAvailabilityCheck({fromDependency: contribs, mode: 'empty'}),
+    exposeDependency({dependency: '#availability'}),
+  ]);
 }
 
 // Neat little shortcut for "reversing" the reference lists stored on other