fix: improper handling of undefined api leading to crashes
This commit is contained in:
9 files changed
+73
-67
No files matched your search
@@ -8,13 +8,11 @@ import React from "react";
|
||||
|
||||
const PlayNextButton = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
if (!api) {
|
||||
console.error("Unable to display play next button, api is not available");
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
const result = await getUserApi(api).getCurrentUser();
|
||||
return result.data;
|
||||
},
|
||||
@@ -22,7 +20,7 @@ const PlayNextButton = () => {
|
||||
const handlePlayNext = useMutation({
|
||||
mutationKey: ["playNextButton"],
|
||||
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
|
||||
onError: (error) => [console.error(error)],
|
||||
onError: (error) => console.error(error),
|
||||
});
|
||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||
state.tracks,
|
||||
|
||||
Reference in new issue
Block a user