refactor: move all buttons to tsx #338
This commit is contained in:
13 files changed
+170
-170
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user