diff options
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 |
commit | f242d1dec3cd905e74eec6ce518781843d5f65d9 (patch) | |
tree | 246e5f42c652f7b518edc7083a78d6b07974105c | |
parent | a8718915ffcb9b3977ccab479817c8bd8d9b20c6 (diff) |
data: update contribsPresent syntax & implementation
-rw-r--r-- | src/data/things/album.js | 6 | ||||
-rw-r--r-- | src/data/things/thing.js | 15 |
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 |