diff --git a/web/src/routes/media/media.tsx b/web/src/routes/media/media.tsx index 15d8981..71a3565 100644 --- a/web/src/routes/media/media.tsx +++ b/web/src/routes/media/media.tsx @@ -2,8 +2,12 @@ import { useNavigate, useSearchParams } from 'react-router-dom' import { FolderIcon, SearchIcon } from '../../../assets' import { Large, Small } from '../../utils/react_responsive' import { useProto } from '../../context/proto' -import { GetDirectoryRequest } from '../../../gen/proto/media/media_pb' -import { useQuery } from '@tanstack/react-query' +import { + GetDirectoryRequest, + GetVideoRequest, +} from '../../../gen/proto/media/media_pb' +import { useQuery, useQueryClient } from '@tanstack/react-query' +import { useState } from 'react' export function Media() { const { MediaServiceClient } = useProto() @@ -12,7 +16,7 @@ export function Media() { const path = searchParams.get('path') || '' const { data } = useQuery({ - queryKey: [path], + queryKey: ['get-directory', path], queryFn: () => MediaServiceClient?.getDirectory(new GetDirectoryRequest({ path })), }) @@ -109,11 +113,28 @@ type FolderProp = { } function Folder({ name, subtitle, path }: FolderProp) { + const queryClient = useQueryClient() + const { MediaServiceClient } = useProto() const [searchParams, setSearchParams] = useSearchParams() + const [isPrefetched, setIsPrefetched] = useState(false) return (