mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
move page stores into pages folder
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { Track, Artist, AlbumInfo } from "../../interfaces";
|
||||
import {
|
||||
getAlbumTracks,
|
||||
getAlbumArtists,
|
||||
getAlbumBio,
|
||||
} from "../../composables/album";
|
||||
|
||||
export default defineStore("album", {
|
||||
state: () => ({
|
||||
info: <AlbumInfo>{},
|
||||
tracks: <Track[]>[],
|
||||
artists: <Artist[]>[],
|
||||
bio: null,
|
||||
}),
|
||||
actions: {
|
||||
/**
|
||||
* Fetches a single album information, artists and its tracks from the server
|
||||
* using the title and album-artist of the album.
|
||||
* @param title title of the album
|
||||
* @param albumartist artist of the album
|
||||
*/
|
||||
async fetchTracksAndArtists(title: string, albumartist: string) {
|
||||
const tracks = await getAlbumTracks(title, albumartist);
|
||||
const artists = await getAlbumArtists(title, albumartist);
|
||||
|
||||
this.tracks = tracks.tracks;
|
||||
this.info = tracks.info;
|
||||
this.artists = artists;
|
||||
},
|
||||
/**
|
||||
* Fetches the album bio from the server
|
||||
* @param title title of the album
|
||||
* @param albumartist artist of the album
|
||||
*/
|
||||
fetchBio(title: string, albumartist: string) {
|
||||
this.bio = null;
|
||||
getAlbumBio(title, albumartist).then((bio) => {
|
||||
this.bio = bio;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user