add comments to some store functions

- some refactors to modals
This commit is contained in:
geoffrey45
2022-05-13 20:50:58 +03:00
parent 2e274dac1d
commit 8b62fe78fa
12 changed files with 106 additions and 81 deletions
+11
View File
@@ -14,6 +14,12 @@ export default defineStore("album", {
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);
@@ -22,6 +28,11 @@ export default defineStore("album", {
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) => {
+6 -2
View File
@@ -19,9 +19,13 @@ export default defineStore("newModal", {
this.component = modalOption;
this.visible = true;
},
showNewPlaylistModal(track: Track) {
showNewPlaylistModal(track?: Track) {
this.component = ModalOptions.newPlaylist;
this.props.track = track;
if (track) {
this.props.track = track;
}
this.visible = true;
},
showEditPlaylistModal(playlist: Playlist) {
+10
View File
@@ -8,11 +8,21 @@ export default defineStore("playlist-tracks", {
tracks: <Track[]>[],
}),
actions: {
/**
* Fetches a single playlist information, and its tracks from the server
* @param playlistid The id of the playlist to fetch
*/
async fetchAll(playlistid: string) {
const playlist = await getPlaylist(playlistid);
this.info = playlist.info;
this.tracks = playlist.tracks;
},
/**
* Updates the playlist header info. This is used when the playlist is
* updated.
* @param info Playlist info
*/
updatePInfo(info: Playlist) {
this.info = info;
},
+12
View File
@@ -7,10 +7,22 @@ export default defineStore("playlists", {
playlists: <Playlist[]>[],
}),
actions: {
/**
* Fetch all playlists from the server
*/
async fetchAll() {
const playlists = await getAllPlaylists();
this.playlists = playlists;
},
/**
* Adds a single playlist to the store
* @param playlist Playlist to add to the store
* @returns void
*/
addPlaylist(playlist: Playlist) {
// add at the beginning
this.playlists.unshift(playlist);
},
},
});