diff --git a/package.json b/package.json index e3b0314..4fd8022 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "blink", "private": true, - "version": "0.0.6-dev", + "version": "0.0.7-dev", "type": "module", "scripts": { "dev": "vite --force && tsr watch", diff --git a/src/components/outroCard/index.tsx b/src/components/outroCard/index.tsx index af043df..d0b1921 100644 --- a/src/components/outroCard/index.tsx +++ b/src/components/outroCard/index.tsx @@ -1,5 +1,5 @@ import { useApiInContext } from "@/utils/store/api"; -import { playItemFromQueue, usePlaybackStore } from "@/utils/store/playback"; +import { playItemFromQueue } from "@/utils/store/playback"; import useQueue from "@/utils/store/queue"; import { Button, Typography } from "@mui/material"; import React from "react"; @@ -7,8 +7,8 @@ import { getTypeIcon } from "../utils/iconsCollection"; import "./outroCard.scss"; import getImageUrlsApi from "@/utils/methods/getImageUrlsApi"; -import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; -import { useMutation, useQuery } from "@tanstack/react-query"; +import { useCentralStore } from "@/utils/store/central"; +import { useMutation } from "@tanstack/react-query"; const OutroCard = (props: { handleShowCredits: () => void }) => { const api = useApiInContext((s) => s.api); @@ -16,19 +16,14 @@ const OutroCard = (props: { handleShowCredits: () => void }) => { s.currentItemIndex, s.tracks, ]); - const item = queueItems[nextItemIndex + 1]; - const user = useQuery({ - queryKey: ["user"], - queryFn: async () => { - const result = await getUserApi(api).getCurrentUser(); - return result.data; - }, - }); + const item = queueItems?.[nextItemIndex + 1]; + const user = useCentralStore((s) => s.currentUser); const handlePlayNext = useMutation({ mutationKey: ["playNextButton"], - mutationFn: () => playItemFromQueue("next", user.data?.Id, api), + mutationFn: () => playItemFromQueue("next", user?.Id, api), onError: (error) => [console.error(error)], }); + if (!item || !item.Type) return null; return (
Up Next @@ -37,14 +32,21 @@ const OutroCard = (props: { handleShowCredits: () => void }) => { {item.Name ) : (
- {getTypeIcon(item?.Type)} + {getTypeIcon(item.Type)}
)} @@ -56,6 +58,7 @@ const OutroCard = (props: { handleShowCredits: () => void }) => {
- {currentDraggingIndex && currentDraggingIndex >= 0 && ( + {(currentDraggingIndex ?? -1) >= 0 && (
drag_handle
- {queue[currentDraggingIndex].Name} + {queue[currentDraggingIndex ?? 0].Name} - {queue[currentDraggingIndex].Artists?.join(", ")} + {queue[currentDraggingIndex ?? 0].Artists?.join(", ")}
{getRuntimeMusic( - queue[currentDraggingIndex].RunTimeTicks ?? 0, + queue[currentDraggingIndex ?? 0].RunTimeTicks ?? 0, )}