diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-10-23 18:16:16 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-10-23 18:19:16 -0300 |
| commit | e100804966122cd730a0ec4bf55ad10e10b6be60 (patch) | |
| tree | ba13e4e7c3cc0bdf2685536d127084750953a71b /src | |
| parent | 91214d3e8482e3128f1c7a2d6da240ef0413a59d (diff) | |
content: generateTrackListItem: showArtists: 'auto'
Diffstat (limited to 'src')
| -rw-r--r-- | src/content/dependencies/generateAlbumTrackListItem.js | 2 | ||||
| -rw-r--r-- | src/content/dependencies/generateTrackList.js | 2 | ||||
| -rw-r--r-- | src/content/dependencies/generateTrackListItem.js | 62 |
3 files changed, 40 insertions, 26 deletions
diff --git a/src/content/dependencies/generateAlbumTrackListItem.js b/src/content/dependencies/generateAlbumTrackListItem.js index ab8d477d..68722a83 100644 --- a/src/content/dependencies/generateAlbumTrackListItem.js +++ b/src/content/dependencies/generateAlbumTrackListItem.js @@ -40,7 +40,7 @@ export default { generate: (data, relations, slots) => relations.item.slots({ - showArtists: true, + showArtists: 'auto', showDuration: (slots.collapseDurationScope === 'track' diff --git a/src/content/dependencies/generateTrackList.js b/src/content/dependencies/generateTrackList.js index e30feb23..6771285a 100644 --- a/src/content/dependencies/generateTrackList.js +++ b/src/content/dependencies/generateTrackList.js @@ -27,7 +27,7 @@ export default { relations.items.map(item => item.slots({ - showArtists: true, + showArtists: 'auto', showDuration: false, colorMode: slots.colorMode, }))), diff --git a/src/content/dependencies/generateTrackListItem.js b/src/content/dependencies/generateTrackListItem.js index 9de9c3a6..c4b7c21e 100644 --- a/src/content/dependencies/generateTrackListItem.js +++ b/src/content/dependencies/generateTrackListItem.js @@ -3,12 +3,18 @@ export default { trackLink: relation('linkTrack', track), - credit: + contextualCredit: relation('generateArtistCredit', track.artistContribs, contextContributions, track.artistText), + acontextualCredit: + relation('generateArtistCredit', + track.artistContribs, + [], + track.artistText), + colorStyle: relation('generateColorStyleAttribute', track.color), @@ -27,12 +33,11 @@ export default { }), slots: { - // showArtists enables showing artists *at all.* It doesn't take precedence - // over behavior which automatically collapses (certain) artists because of - // provided context contributions. + // true always shows artists, false never does; 'auto' shows only if + // the track's artists differ from the given context contributions. showArtists: { - type: 'boolean', - default: true, + validate: v => v.is(true, false, 'auto'), + default: 'auto', }, // If true and the track doesn't have a duration, a missing-duration cue @@ -72,24 +77,33 @@ export default { : relations.missingDuration); } - const artistCapsule = language.encapsulate(itemCapsule, 'withArtists'); - - relations.credit.setSlots({ - normalStringKey: - artistCapsule + '.by', - - featuringStringKey: - artistCapsule + '.featuring', - - normalFeaturingStringKey: - artistCapsule + '.by.featuring', - }); - - if (!html.isBlank(relations.credit)) { - workingCapsule += '.withArtists'; - workingOptions.by = - html.tag('span', {class: 'by'}, - relations.credit); + const chosenCredit = + (slots.showArtists === true + ? relations.acontextualCredit + : slots.showArtists === 'auto' + ? relations.contextualCredit + : null); + + if (chosenCredit) { + const artistCapsule = language.encapsulate(itemCapsule, 'withArtists'); + + chosenCredit.setSlots({ + normalStringKey: + artistCapsule + '.by', + + featuringStringKey: + artistCapsule + '.featuring', + + normalFeaturingStringKey: + artistCapsule + '.by.featuring', + }); + + if (!html.isBlank(chosenCredit)) { + workingCapsule += '.withArtists'; + workingOptions.by = + html.tag('span', {class: 'by'}, + chosenCredit); + } } return language.$(workingCapsule, workingOptions); |