« get me outta code hell

data: update contribsPresent syntax & implementation - 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-09 09:40:15 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-09 09:40:25 -0300
commitf242d1dec3cd905e74eec6ce518781843d5f65d9 (patch)
tree246e5f42c652f7b518edc7083a78d6b07974105c /src/data/things/thing.js
parenta8718915ffcb9b3977ccab479817c8bd8d9b20c6 (diff)
data: update contribsPresent syntax & implementation
Diffstat (limited to 'src/data/things/thing.js')
-rw-r--r--src/data/things/thing.js15
1 files changed, 6 insertions, 9 deletions
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