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,16 @@ 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 { useRouteContext } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
|
||||
const PlayPreviousButton = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
if (!api) {
|
||||
console.error(
|
||||
"Unable to display play previous button, api is not available",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
@@ -21,10 +26,7 @@ const PlayPreviousButton = () => {
|
||||
mutationFn: () => playItemFromQueue("previous", user.data?.Id, api),
|
||||
onError: (error) => [console.error(error)],
|
||||
});
|
||||
const [queueItems, currentItemIndex] = useQueue((state) => [
|
||||
state.tracks,
|
||||
state.currentItemIndex,
|
||||
]);
|
||||
const [currentItemIndex] = useQueue((state) => [state.currentItemIndex]);
|
||||
return (
|
||||
<IconButton
|
||||
disabled={currentItemIndex === 0}
|
||||
|
||||
Reference in new issue
Block a user