feat: add API availability checks and fallback for cover art in various components

This commit is contained in:
2025-06-22 21:10:15 -05:00
parent 6fcf58e7ba
commit b07685fe79
12 changed files with 78 additions and 38 deletions

View File

@@ -22,11 +22,13 @@ const RadioStationsPage = () => {
});
const { toast } = useToast();
const { playTrack } = useAudioPlayer();
const loadRadioStations = useCallback(async () => {
setIsLoading(true);
try {
const api = getNavidromeAPI();
if (!api) {
throw new Error('Navidrome API not available');
}
const stationList = await api.getInternetRadioStations();
setStations(stationList);
} catch (error) {
@@ -53,10 +55,11 @@ const RadioStationsPage = () => {
variant: "destructive"
});
return;
}
try {
} try {
const api = getNavidromeAPI();
if (!api) {
throw new Error('Navidrome API not available');
}
await api.createInternetRadioStation(
newStation.name,
newStation.streamUrl,
@@ -81,9 +84,11 @@ const RadioStationsPage = () => {
}
};
const deleteRadioStation = async (stationId: string) => {
try {
const deleteRadioStation = async (stationId: string) => { try {
const api = getNavidromeAPI();
if (!api) {
throw new Error('Navidrome API not available');
}
await api.deleteInternetRadioStation(stationId);
toast({