attach artist page link to ArtistName component

+ separate fetching artist albums with fetching artist info
+ include limit when fetching artist albums
+ refactor interfaces
This commit is contained in:
geoffrey45
2022-12-05 18:27:55 +03:00
committed by Mungai Njoroge
parent e54fea2d4d
commit 580dce1da9
14 changed files with 162 additions and 53 deletions
+16 -3
View File
@@ -1,7 +1,8 @@
import { defineStore } from "pinia";
import { Artist, Album, Track } from "@/interfaces";
import { getArtistData } from "@/composables/fetch/artists";
import { getArtistData, getArtistAlbums } from "@/composables/fetch/artists";
import { maxAbumCards } from "@/stores/content-width";
export default defineStore("artistPage", {
state: () => ({
@@ -11,11 +12,23 @@ export default defineStore("artistPage", {
}),
actions: {
async getData(hash: string) {
const { artist, albums, tracks } = await getArtistData(hash);
const { artist, tracks } = await getArtistData(hash);
this.info = artist;
this.tracks = tracks;
this.albums = albums;
},
async getArtistAlbums() {
const albums = await getArtistAlbums(
this.info.artisthash,
maxAbumCards.value
);
if (albums.length > 0) {
this.albums = albums;
}
},
resetAlbums() {
this.albums = [];
},
},
});