diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-06-01 08:13:30 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-06-01 08:13:30 -0300 |
| commit | 3e4c76abc6c7d6d9d4e148a4a188207b1b96bd4c (patch) | |
| tree | 286c4e62b53643614063bb39a76cc768acae889a | |
| parent | 1631d1b3129fd37d7396cc03abe2d76ad37e2c39 (diff) | |
data: Track: new contribs on secrelease count toward totals preview
| -rw-r--r-- | src/data/things/Track.js | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/data/things/Track.js b/src/data/things/Track.js index 7ce55e51..ca3e82f7 100644 --- a/src/data/things/Track.js +++ b/src/data/things/Track.js @@ -1453,30 +1453,65 @@ export class Track extends Thing { return this.album.getAlbumArtPath(filename); } - countOwnContributionInContributionTotals(_contrib) { + countOwnContributionInContributionTotals(contrib) { if (!this.countInArtistTotals) { return false; } if (this.isSecondaryRelease) { - return false; + const correspondingContrib = + this.getCorrespondingMainReleaseContrib(contrib); + + if (correspondingContrib) { + return false; + } } return true; } - countOwnContributionInDurationTotals(_contrib) { + countOwnContributionInDurationTotals(contrib) { if (!this.countInArtistTotals) { return false; } if (this.isSecondaryRelease) { - return false; + const correspondingContrib = + this.getCorrespondingMainReleaseContrib(contrib); + + if (correspondingContrib) { + return false; + } } return true; } + getCorrespondingMainReleaseContrib(contrib) { + if (!this.isSecondaryRelease) return null; + + const filterMatchingContrib = c => + c.artist === contrib.artist && + c.annotation === contrib.annotation; + + const myList = + this[contrib.thingProperty] + .filter(filterMatchingContrib); + + const mainList = + this.mainReleaseTrack[contrib.thingProperty] + .filter(filterMatchingContrib); + + const index = myList.indexOf(contrib); + + if (index === -1) { + const key = contrib.thingProperty; + throw new Error(`Couldn't find contribution in track's own ${key}`); + } + + return mainList.at(index) ?? null; + } + [inspect.custom](depth) { const parts = []; |