From 0aee1b3918d886b67ad84348372212f4dd3407ef Mon Sep 17 00:00:00 2001 From: Thomas Amland Date: Sat, 15 Aug 2020 09:47:07 +0200 Subject: [PATCH] sort albums chronologically on artist page. fixes #10 --- src/shared/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/api.ts b/src/shared/api.ts index 0f580db..58e450c 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -283,6 +283,10 @@ export class API { } private normalizeArtist(item: any): Artist { + const albums = item.album + ?.map(this.normalizeAlbum, this) + .sort((a: any, b: any) => b.year - a.year) + return { id: item.id, name: item.name, @@ -294,7 +298,7 @@ export class API { musicBrainzUrl: item.musicBrainzId ? `https://musicbrainz.org/artist/${item.musicBrainzId}` : undefined, - albums: item.album?.map(this.normalizeAlbum, this), + albums, similarArtist: (item.similarArtist || []).map(this.normalizeArtist, this) } }