+
+
- Albums
+ {{ releaseType }}
-
+
{{ year || 'Unknown' }}
@@ -132,8 +132,21 @@
isFavourite(): boolean {
return !!this.favouriteStore.artists[this.id]
},
- albums(): Album[] {
- return orderBy(this.item?.albums ?? [], 'year', this.mainStore.artistAlbumSortOrder)
+ albums(): { releaseType: string, albums: Album[] }[] {
+ const sorted: Album[] = (orderBy(this.item?.albums ?? [], 'year', this.mainStore.artistAlbumSortOrder) || [])
+ const grouped = Object.groupBy(sorted, ({ isCompilation, releaseTypes }) =>
+ isCompilation ? 'Compilation' : (releaseTypes[0] || 'Album')
+ ) || {}
+
+ const groupOrder = ['Album', 'EP', 'Single']
+ const groups = Object.entries(grouped).sort(([aType], [bType]) => {
+ const [a, b] = [groupOrder.indexOf(aType), groupOrder.indexOf(bType)]
+ if (a === -1 && b === -1) return 0
+ if (a === -1) return 1
+ if (b === -1) return -1
+ return a - b
+ })
+ return groups.map(([releaseType, albums]) => ({ releaseType, albums: albums || [] }))
},
},
watch: {
diff --git a/src/shared/api.ts b/src/shared/api.ts
index ade5f716..9e2384c4 100644
--- a/src/shared/api.ts
+++ b/src/shared/api.ts
@@ -48,6 +48,8 @@ export interface Album {
lastFmUrl?: string
musicBrainzUrl?: string
tracks?: Track[]
+ isCompilation: boolean
+ releaseTypes: string[]
}
export interface Artist {
@@ -591,7 +593,9 @@ export class API {
musicBrainzUrl: item.musicBrainzId
? `https://musicbrainz.org/release/${item.musicBrainzId}`
: undefined,
- tracks: (item.song || []).map(this.normalizeTrack, this)
+ tracks: (item.song || []).map(this.normalizeTrack, this),
+ isCompilation: !!item.isCompilation,
+ releaseTypes: item.releaseTypes.length ? item.releaseTypes : [],
}
}