mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
show toast if album return 204
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import axios, { AxiosError } from "axios";
|
||||
import state from "../state";
|
||||
import { AlbumInfo, Track } from "../../interfaces";
|
||||
import useAxios from "../useAxios";
|
||||
import { NotifType, useNotifStore } from "@/stores/notification";
|
||||
|
||||
const getAlbumTracks = async (album: string, artist: string) => {
|
||||
const getAlbumData = async (
|
||||
album: string,
|
||||
artist: string,
|
||||
ToastStore: typeof useNotifStore
|
||||
) => {
|
||||
const url = state.settings.uri + "/album";
|
||||
|
||||
interface AlbumData {
|
||||
@@ -19,9 +23,13 @@ const getAlbumTracks = async (album: string, artist: string) => {
|
||||
},
|
||||
});
|
||||
|
||||
if (status == 404) {
|
||||
if (status == 204) {
|
||||
ToastStore().showNotification("Album not created yet!", NotifType.Error);
|
||||
return {
|
||||
info: {},
|
||||
info: {
|
||||
album: album,
|
||||
artist: artist,
|
||||
},
|
||||
tracks: [],
|
||||
};
|
||||
}
|
||||
@@ -63,4 +71,4 @@ const getAlbumBio = async (album: string, albumartist: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getAlbumTracks, getAlbumArtists, getAlbumBio };
|
||||
export { getAlbumData as getAlbumTracks, getAlbumArtists, getAlbumBio };
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { useNotifStore } from "../notification";
|
||||
import { Track, Artist, AlbumInfo } from "../../interfaces";
|
||||
import {
|
||||
getAlbumTracks,
|
||||
@@ -21,7 +22,7 @@ export default defineStore("album", {
|
||||
* @param albumartist artist of the album
|
||||
*/
|
||||
async fetchTracksAndArtists(title: string, albumartist: string) {
|
||||
const tracks = await getAlbumTracks(title, albumartist);
|
||||
const tracks = await getAlbumTracks(title, albumartist, useNotifStore);
|
||||
const artists = await getAlbumArtists(title, albumartist);
|
||||
|
||||
this.tracks = tracks.tracks;
|
||||
|
||||
Reference in New Issue
Block a user