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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
import {empty} from '#sugar';
export default {
contentDependencies: ['generateArtistCredit'],
extraDependencies: ['language'],
query(album, group) {
if (album.groups.length > 1) {
const contextGroup = group;
const candidateGroupCategory =
album.groups
.filter(group => !group.excludeFromGalleryTabs)
.find(group => group.category !== contextGroup.category)
?.category ??
null;
const candidateGroups =
album.groups
.filter(group => !group.excludeFromGalleryTabs)
.filter(group => group.category === candidateGroupCategory);
if (!empty(candidateGroups)) {
return {
mode: 'groups',
notedGroups: candidateGroups,
};
}
}
if (!empty(album.artistContribs)) {
if (
album.artistContribs.length === 1 &&
!empty(group.closelyLinkedArtists) &&
(album.artistContribs[0].artist.name ===
group.closelyLinkedArtists[0].artist.name)
) {
return {mode: null};
}
return {
mode: 'artists',
notedArtistContribs: album.artistContribs,
};
}
return {mode: null};;
},
relations: (relation, query, _album, _group) => ({
artistCredit:
(query.mode === 'artists'
? relation('generateArtistCredit', query.notedArtistContribs, [])
: null),
}),
data: (query, _album, _group) => ({
mode: query.mode,
groupNames:
(query.mode === 'groups'
? query.notedGroups.map(group => group.name)
: null),
}),
generate: (data, relations, {language}) =>
language.encapsulate('misc.coverGrid.tab', capsule =>
(data.mode === 'groups'
? language.$(capsule, 'groups', {
groups:
language.formatUnitList(data.groupNames),
})
: data.mode === 'artists'
? relations.artistCredit.slots({
normalStringKey:
capsule + '.artists',
normalFeaturingStringKey:
capsule + '.artists.featuring',
})
: null)),
};
|