diff options
-rw-r--r-- | src/data/composite/things/track-section/withAlbum.js | 6 | ||||
-rw-r--r-- | src/data/things/album.js | 19 | ||||
-rw-r--r-- | src/data/yaml.js | 4 | ||||
-rw-r--r-- | test/unit/data/things/album.js | 88 | ||||
-rw-r--r-- | test/unit/data/things/art-tag.js | 5 | ||||
-rw-r--r-- | test/unit/data/things/track.js | 22 |
6 files changed, 40 insertions, 104 deletions
diff --git a/src/data/composite/things/track-section/withAlbum.js b/src/data/composite/things/track-section/withAlbum.js index 608cc0cd..a4dfff0d 100644 --- a/src/data/composite/things/track-section/withAlbum.js +++ b/src/data/composite/things/track-section/withAlbum.js @@ -1,6 +1,4 @@ -// Gets the track section's album. This will early exit if ownAlbumData is -// missing. If there's no album whose list of track sections includes this one, -// the output dependency will be null. +// Gets the track section's album. import {input, templateCompositeFrom} from '#composite'; @@ -13,7 +11,7 @@ export default templateCompositeFrom({ steps: () => [ withUniqueReferencingThing({ - data: 'ownAlbumData', + data: 'albumData', list: input.value('trackSections'), }).outputs({ ['#uniqueReferencingThing']: '#album', diff --git a/src/data/things/album.js b/src/data/things/album.js index f1a7df3d..82f155b4 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -440,15 +440,8 @@ export class Album extends Thing { } currentTrackSection.tracks = - currentTrackSectionTracks - .map(track => Thing.getReference(track)); - - currentTrackSection.ownTrackData = currentTrackSectionTracks; - currentTrackSection.ownAlbumData = - [album]; - trackSections.push(currentTrackSection); trackSectionData.push(currentTrackSection); }; @@ -521,22 +514,16 @@ export class TrackSection extends Thing { exposeDependency({dependency: '#album'}), ], - tracks: referenceList({ + tracks: thingList({ class: input.value(Track), - data: 'ownTrackData', - find: input.value(find.track), }), // Update only - ownAlbumData: wikiData({ + albumData: wikiData({ class: input.value(Album), }), - ownTrackData: wikiData({ - class: input.value(Track), - }), - // Expose only directory: [ @@ -655,8 +642,6 @@ export class TrackSection extends Thing { length = this.tracks.length; } catch {} - album ??= CacheableObject.getUpdateValue(this, 'ownAlbumData')?.[0]; - if (album) { const albumName = album.name; const albumIndex = album.trackSections.indexOf(this); diff --git a/src/data/yaml.js b/src/data/yaml.js index 7a16341b..ffa24669 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1206,6 +1206,10 @@ export function linkWikiDataArrays(wikiData) { 'wikiInfo', ]], + [wikiData.trackSectionData, [ + 'albumData', + ]], + [[wikiData.wikiInfo], [ 'groupData', ]], diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js index e9c0d700..8be9d9ee 100644 --- a/test/unit/data/things/album.js +++ b/test/unit/data/things/album.js @@ -38,9 +38,8 @@ function stubTrack(directory = 'foo') { function stubTrackSection(album, tracks, directory = 'baz') { const trackSection = new TrackSection(); trackSection.unqualifiedDirectory = directory; - trackSection.tracks = tracks.map(t => Thing.getReference(t)); - trackSection.ownTrackData = tracks; - trackSection.ownAlbumData = [album]; + trackSection.tracks = tracks; + trackSection.albumData = [album]; return trackSection; } @@ -244,7 +243,7 @@ t.test(`Album.coverArtFileExtension`, t => { }); t.test(`Album.tracks`, t => { - t.plan(5); + t.plan(4); const album = new Album(); album.directory = 'foo'; @@ -267,64 +266,38 @@ t.test(`Album.tracks`, t => { } for (const section of sections) { - section.ownAlbumData = [album]; + section.albumData = [album]; } t.same(album.tracks, [], `Album.tracks #1: defaults to empty array`); - section1.tracks = ['track:track1', 'track:track2', 'track:track3']; - section1.ownTrackData = [track1, track2, track3]; + section1.tracks = [track1, track2, track3]; album.trackSections = [section1]; t.same(album.tracks, [track1, track2, track3], `Album.tracks #2: pulls tracks from one track section`); - section1.tracks = ['track:track1']; - section2.tracks = ['track:track2', 'track:track3']; - - section1.ownTrackData = [track1]; - section2.ownTrackData = [track2, track3]; + section1.tracks = [track1]; + section2.tracks = [track2, track3]; album.trackSections = [section1, section2]; t.same(album.tracks, [track1, track2, track3], `Album.tracks #3: pulls tracks from multiple track sections`); - section1.tracks = ['track:track1', 'track:does-not-exist']; - section2.tracks = ['track:this-one-neither', 'track:track2']; - section3.tracks = ['track:effectively-empty-section']; - section4.tracks = ['track:track3']; - - section1.ownTrackData = [track1]; - section2.ownTrackData = [track2]; - section3.ownTrackData = []; - section4.ownTrackData = [track3]; - - album.trackSections = [section1, section2, section3, section4]; - - t.same(album.tracks, [track1, track2, track3], - `Album.tracks #4: filters out references without matches`); - - section1.tracks = ['track:track1']; + section1.tracks = [track1]; section2.tracks = []; - section3.tracks = ['track:track2']; + section3.tracks = [track2]; section4.tracks = []; section5.tracks = []; - section6.tracks = ['track:track3']; - - section1.ownTrackData = [track1]; - section2.ownTrackData = []; - section3.ownTrackData = [track2]; - section4.ownTrackData = []; - section5.ownTrackData = []; - section6.ownTrackData = [track3]; + section6.tracks = [track3]; album.trackSections = [section1, section2, section3, section4, section5, section6]; t.same(album.tracks, [track1, track2, track3], - `Album.tracks #5: skips empty track sections`); + `Album.tracks #4: skips empty track sections`); }); t.test(`Album.trackSections`, t => { @@ -345,21 +318,12 @@ t.test(`Album.trackSections`, t => { const section5 = stubTrackSection(album, [], 'section5'); const sections = [section1, section2, section3, section4, section5]; - const section1_ref = `unqualified-track-section:section1`; - const section2_ref = `unqualified-track-section:section2`; - const section3_ref = `unqualified-track-section:section3`; - const section4_ref = `unqualified-track-section:section4`; - const section5_ref = `unqualified-track-section:section5`; - for (const track of tracks) { track.albumData = [album]; } - section1.tracks = ['track:track1', 'track:track2']; - section2.tracks = ['track:track3', 'track:track4']; - - section1.ownTrackData = [track1, track2]; - section2.ownTrackData = [track3, track4]; + section1.tracks = [track1, track2]; + section2.tracks = [track3, track4]; album.trackSections = [section1, section2]; @@ -373,13 +337,9 @@ t.test(`Album.trackSections`, t => { {tracks: [track3, track4], startIndex: 2}, ], `Album.trackSections #2: exposes startIndex`); - section1.tracks = ['track:track1']; - section2.tracks = ['track:track2']; - section3.tracks = ['track:track3']; - - section1.ownTrackData = [track1]; - section2.ownTrackData = [track2]; - section3.ownTrackData = [track3]; + section1.tracks = [track1]; + section2.tracks = [track2]; + section3.tracks = [track3]; section1.name = 'First section'; section2.name = 'Second section'; @@ -431,17 +391,11 @@ t.test(`Album.trackSections`, t => { {tracks: [track3], isDefaultTrackSection: false}, ], `Album.trackSections #6: exposes isDefaultTrackSection, defaults to false`); - section1.tracks = ['track:track1', 'track:track2', 'track:snooping']; - section2.tracks = ['track:track3', 'track:as-usual']; + section1.tracks = [track1, track2]; + section2.tracks = [track3]; section3.tracks = []; - section4.tracks = ['track:icy', 'track:chilly', 'track:frigid']; - section5.tracks = ['track:track4']; - - section1.ownTrackData = [track1, track2]; - section2.ownTrackData = [track3]; - section3.ownTrackData = []; - section4.ownTrackData = []; - section5.ownTrackData = [track4]; + section4.tracks = []; + section5.tracks = [track4]; section1.color = '#112233'; section2.color = '#334455'; @@ -457,7 +411,7 @@ t.test(`Album.trackSections`, t => { {tracks: [], color: '#bbbbba'}, {tracks: [], color: '#556677'}, {tracks: [track4], color: '#778899'}, - ], `Album.trackSections #7: filters out references without matches, keeps empty sections`); + ], `Album.trackSections #7: keeps empty sections`); }); t.test(`Album.wallpaperFileExtension`, t => { diff --git a/test/unit/data/things/art-tag.js b/test/unit/data/things/art-tag.js index cf2135c6..e4879326 100644 --- a/test/unit/data/things/art-tag.js +++ b/test/unit/data/things/art-tag.js @@ -25,9 +25,8 @@ function stubAlbum(tracks, directory = 'bar') { function stubTrackSection(album, tracks, directory = 'baz') { const trackSection = new TrackSection(); trackSection.unqualifiedDirectory = directory; - trackSection.tracks = tracks.map(t => Thing.getReference(t)); - trackSection.ownTrackData = tracks; - trackSection.ownAlbumData = [album]; + trackSection.tracks = tracks; + trackSection.albumData = [album]; return trackSection; } diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js index e27fb449..3fe4b4de 100644 --- a/test/unit/data/things/track.js +++ b/test/unit/data/things/track.js @@ -27,9 +27,8 @@ function stubAlbum(tracks, directory = 'bar') { function stubTrackSection(album, tracks, directory = 'baz') { const trackSection = new TrackSection(); trackSection.unqualifiedDirectory = directory; - trackSection.tracks = tracks.map(t => Thing.getReference(t)); - trackSection.ownTrackData = tracks; - trackSection.ownAlbumData = [album]; + trackSection.tracks = tracks; + trackSection.albumData = [album]; return trackSection; } @@ -101,12 +100,10 @@ t.test(`Track.album`, t => { track1.albumData = [album1, album2]; track2.albumData = [album1, album2]; - section1.ownTrackData = [track1]; - section2.ownTrackData = [track2]; - section1.ownAlbumData = [album1]; - section2.ownAlbumData = [album2]; - section1.tracks = ['track:track1']; - section2.tracks = ['track:track2']; + section1.tracks = [track1]; + section2.tracks = [track2]; + section1.albumData = [album1]; + section2.albumData = [album2]; album1.trackSections = [section1]; album2.trackSections = [section2]; @@ -123,7 +120,7 @@ t.test(`Track.album`, t => { t.equal(track1.album, null, `album #4: is null when track missing albumData`); - section1.ownTrackData = []; + section1.tracks = []; // XXX_decacheWikiData album1.trackSections = []; @@ -132,10 +129,9 @@ t.test(`Track.album`, t => { track1.albumData = [album2, album1]; t.equal(track1.album, null, - `album #5: is null when album track section missing ownTrackData`); + `album #5: is null when album track section missing tracks`); - section1.ownTrackData = [track2]; - section1.tracks = ['track:track2']; + section1.tracks = [track2]; // XXX_decacheWikiData album1.trackSections = []; |