refactor: move all buttons to tsx #338

This commit is contained in:
Prayag Prajapati committed 2024-11-24 23:46:20 +05:30
1 parent 9be02b6392
commit c6b5d6a4a2
13 files changed
+170 -170

No files matched your search

+5 -3
View File
@@ -4,11 +4,14 @@ import useQueue from "@/utils/store/queue";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { IconButton } from "@mui/material";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useNavigate, useRouteContext } from "@tanstack/react-router";
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 () => {
@@ -16,7 +19,6 @@ const PlayNextButton = () => {
return result.data;
},
});
const navigate = useNavigate();
const handlePlayNext = useMutation({
mutationKey: ["playNextButton"],
mutationFn: () => playItemFromQueue("next", user.data?.Id, api),
@@ -28,7 +30,7 @@ const PlayNextButton = () => {
]);
return (
<IconButton
disabled={queueItems.length === currentItemIndex + 1}
disabled={queueItems?.length === currentItemIndex + 1}
onClick={() => handlePlayNext.mutate()}
>
<span className="material-symbols-rounded">skip_next</span>