import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api"; import { Divider, Drawer, List, ListItem, ListItemButton, Typography, } from "@mui/material"; import { useQuery } from "@tanstack/react-query"; import React, { useEffect, useMemo } from "react"; import { useApiInContext } from "@/utils/store/api"; import { useCentralStore } from "@/utils/store/central"; import ListItemLink from "../listItemLink"; import { getTypeIcon } from "../utils/iconsCollection"; interface NavigationDrawerProps { open: boolean; onClose: () => void; } export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => { const api = useApiInContext((s) => s.api); const user = useCentralStore((s) => s.currentUser); const libraries = useQuery({ queryKey: ["libraries"], queryFn: async () => { if (!user?.Id || !api?.accessToken) { return; } const libs = await getUserViewApi(api).getUserViews({ userId: user.Id, }); return libs.data; }, enabled: !!user?.Id && !!api?.accessToken, networkMode: "always", }); // Libraries can be added on the server while the app is running; refresh // the view list every time the drawer opens so they show up without restart. const refetchLibraries = libraries.refetch; useEffect(() => { if (open) refetchLibraries(); }, [open, refetchLibraries]); const drawerPaperProps = useMemo(() => { return { className: "glass library-drawer", elevation: 6, }; }, []); return ( menu_open
Закрыть
Обзор {libraries.isSuccess && libraries.data?.Items?.map((library) => ( ))} Настройки
); };