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;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { Folder, Track } from "../../interfaces";
|
||||
|
||||
import fetchThem from "../../composables/getFilesAndFolders";
|
||||
|
||||
export default defineStore("FolderDirs&Tracks", {
|
||||
state: () => ({
|
||||
path: <string>{},
|
||||
dirs: <Folder[]>[],
|
||||
tracks: <Track[]>[],
|
||||
}),
|
||||
actions: {
|
||||
async fetchAll(path: string) {
|
||||
const { tracks, folders } = await fetchThem(path);
|
||||
|
||||
this.path = path;
|
||||
this.dirs = folders;
|
||||
this.tracks = tracks;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { getPlaylist } from "../../composables/playlists";
|
||||
import { Track, Playlist } from "../../interfaces";
|
||||
|
||||
export default defineStore("playlist-tracks", {
|
||||
state: () => ({
|
||||
info: <Playlist>{},
|
||||
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;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { Playlist } from "../../interfaces";
|
||||
import { getAllPlaylists } from "../../composables/playlists";
|
||||
|
||||
export default defineStore("playlists", {
|
||||
state: () => ({
|
||||
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);
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user