diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-03-05 21:54:59 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-03-05 21:55:19 -0400 |
commit | c5b42b7883025bb3464b52248567133cd0658959 (patch) | |
tree | 9e6e632ad157584a123d35adccccc0a39dcd11d9 /src/data | |
parent | c235939a92104dd1083f40fc0344d9cca45cfb98 (diff) |
compute startIndex dynamically
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/things.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/data/things.js b/src/data/things.js index 941ef2f2..eb01cc16 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -526,11 +526,6 @@ TrackGroup.propertyDescriptors = { } }, - startIndex: { - flags: {update: true, expose: true}, - update: {validate: isWholeNumber} - }, - dateOriginallyReleased: Thing.common.simpleDate(), tracksByRef: Thing.common.referenceList(Track), @@ -562,6 +557,17 @@ TrackGroup.propertyDescriptors = { ) } }, + + startIndex: { + flags: {expose: true}, + + expose: { + dependencies: ['album'], + compute: ({ album, [TrackGroup.instance]: trackGroup }) => (album.trackGroups + .slice(0, album.trackGroups.indexOf(trackGroup)) + .reduce((acc, tg) => acc + tg.tracks.length, 0)) + } + }, }; // -> Track |