1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Whether or not the track has "unique" cover artwork - a cover which is
// specifically associated with this track in particular, rather than with
// the track's album as a whole. This is typically used to select between
// displaying the track artwork and a fallback, such as the album artwork
// or a placeholder. (This property is named hasUniqueCoverArt instead of
// the usual hasCoverArt to emphasize that it does not inherit from the
// album.)
import {input, templateCompositeFrom} from '#composite';
import {empty} from '#sugar';
import {withResolvedContribs} from '#composite/wiki-data';
import withPropertyFromAlbum from './withPropertyFromAlbum.js';
export default templateCompositeFrom({
annotation: 'withHasUniqueCoverArt',
outputs: ['#hasUniqueCoverArt'],
steps: () => [
{
dependencies: ['disableUniqueCoverArt'],
compute: (continuation, {disableUniqueCoverArt}) =>
(disableUniqueCoverArt
? continuation.raiseOutput({
['#hasUniqueCoverArt']: false,
})
: continuation()),
},
withResolvedContribs({from: 'coverArtistContribs'}),
{
dependencies: ['#resolvedContribs'],
compute: (continuation, {
['#resolvedContribs']: contribsFromTrack,
}) =>
(empty(contribsFromTrack)
? continuation()
: continuation.raiseOutput({
['#hasUniqueCoverArt']: true,
})),
},
withPropertyFromAlbum({
property: input.value('trackCoverArtistContribs'),
}),
{
dependencies: ['#album.trackCoverArtistContribs'],
compute: (continuation, {
['#album.trackCoverArtistContribs']: contribsFromAlbum,
}) =>
continuation.raiseOutput({
['#hasUniqueCoverArt']:
!empty(contribsFromAlbum),
}),
},
],
});
|