Skip to content

Commit 0cb2836

Browse files
authored
MBS-9419: Hide more irrelevant work rels from GroupedTrackRels (metabrainz#1865)
This extends the existing check to skip showing work parts to all other current work-work rels, in the direction that is irrelevant to the recording in question: if the recording is of an arrangement or medley we care about the original works, but if, say, this work has been arranged elsewhere, we don't care about that.
1 parent d4b27bf commit 0cb2836

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

root/components/GroupedTrackRelationships.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ const renderWorkRelationship = (relationship: RelationshipT) => {
7979
);
8080
};
8181

82+
const irrelevantLinkTypes = new Map([
83+
// [id, is backward (direction)]
84+
[239, true], // medleys including this
85+
[241, false], // generic later versions
86+
[281, false], // parts
87+
[314, false], // works based on this
88+
[315, false], // revisions
89+
[316, false], // orchestrations
90+
[350, false], // arrangements
91+
]);
92+
93+
function isIrrelevantLinkType(relationship) {
94+
return irrelevantLinkTypes.get(relationship.linkTypeID) ===
95+
(relationship.direction === 'backward');
96+
}
97+
8298
const GroupedTrackRelationships = ({
8399
source,
84100
}: Props): Array<React.Element<'dl'>> => {
@@ -94,11 +110,11 @@ const GroupedTrackRelationships = ({
94110
) => {
95111
if (targetType === 'work') {
96112
/*
97-
* Specifically ignore work parts, but still keep works this
98-
* work is a part of.
113+
* Specifically ignore rels that do not give information
114+
* relevant to this track, such as other arrangements of the work
115+
* or all the parts of the work linked.
99116
*/
100-
if (relationship.linkTypeID !== 281 ||
101-
relationship.direction === 'backward') {
117+
if (!isIrrelevantLinkType(relationship)) {
102118
workRelationships.push(relationship);
103119
}
104120
return false;

0 commit comments

Comments
 (0)