show toast if album return 204

This commit is contained in:
geoffrey45
2022-06-23 08:30:55 +03:00
parent 5fb920f958
commit de7aba3ba7
7 changed files with 51 additions and 43 deletions
+13 -5
View File
@@ -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 };
+2 -1
View File
@@ -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;