mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Split Album into AlbumSummary and Album as per Artist
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
slice2,
|
||||
asResult,
|
||||
ArtistSummary,
|
||||
Album,
|
||||
AlbumSummary
|
||||
} from "../src/music_service";
|
||||
|
||||
export const artistToArtistSummary = (
|
||||
@@ -24,6 +26,15 @@ export const artistToArtistSummary = (
|
||||
image: it.image,
|
||||
});
|
||||
|
||||
export const albumToAlbumSummary = (
|
||||
it: Album
|
||||
): AlbumSummary => ({
|
||||
id: it.id,
|
||||
name: it.name,
|
||||
year: it.year,
|
||||
genre: it.genre,
|
||||
});
|
||||
|
||||
type P<T> = (t: T) => boolean;
|
||||
const all: P<any> = (_: any) => true;
|
||||
const artistWithId = (id: string): P<Artist> => (artist: Artist) =>
|
||||
@@ -79,8 +90,10 @@ export class InMemoryMusicService implements MusicService {
|
||||
)
|
||||
)
|
||||
.then((artists) => artists.flatMap((it) => it.albums))
|
||||
.then(it => it.map(albumToAlbumSummary))
|
||||
.then(slice2(q))
|
||||
.then(asResult),
|
||||
// album: (id: albumId) => Promise.resolve(this.artists.flatMap(it => it.albums).find(it => it.id === id))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user