Skip to content

Commit cd2da57

Browse files
authored
MBS-11806: Don't group relationships for different track sets (metabrainz#2186)
As far as I can tell, this code was written for relationships that apply to one entity only (one recording, one release...). As such, there was never a need to check for more than "are the rels related, and are the attributes the same". But this now also used for grouped display of medium relationships under a release, and that involves relationships from different tracks. Nothing in the code checked whether the tracks actually matched before they got combined - one of the sets of tracks would just get dropped when combining the two relationship groups. This now makes sure that the tracks also match, if they exist, before allowing a merged display of the relationship.
1 parent a1e492c commit cd2da57

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

root/utility/groupRelationships.js

+19-8
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,25 @@ const areDatedExtraAttributesEqual = (a, b) => (
114114
arraysEqual(a.attributes, b.attributes, areLinkAttrsEqual)
115115
);
116116

117-
const areRelationshipTargetGroupsEqual = (a, b) => (
118-
a.key === b.key &&
119-
arraysEqual(
120-
a.datedExtraAttributesList,
121-
b.datedExtraAttributesList,
122-
areDatedExtraAttributesEqual,
123-
)
124-
);
117+
const areRelationshipTargetGroupsEqual = (a, b) => {
118+
const aTracks = a.tracks;
119+
const bTracks = b.tracks;
120+
121+
return (
122+
a.key === b.key &&
123+
arraysEqual(
124+
a.datedExtraAttributesList,
125+
b.datedExtraAttributesList,
126+
areDatedExtraAttributesEqual,
127+
) &&
128+
(aTracks && bTracks)
129+
? arraysEqual(
130+
Array.from(aTracks),
131+
Array.from(bTracks),
132+
(a, b) => a === b,
133+
) : true
134+
);
135+
};
125136

126137
function displayLinkPhrase(linkTypeInfo) {
127138
const phrase = linkTypeInfo.phrase;

0 commit comments

Comments
 (0)