misc_pterodactyl-panel/resources/scripts/plugins/useFileManagerSwr.ts

20 lines
563 B
TypeScript
Raw Normal View History

import useSWR from 'swr';
import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
import { cleanDirectoryPath } from '@/helpers';
import useServer from '@/plugins/useServer';
import { useLocation } from 'react-router';
export default () => {
const { uuid } = useServer();
const { hash } = useLocation();
return useSWR<FileObject[]>(
`${uuid}:files:${hash}`,
() => loadDirectory(uuid, cleanDirectoryPath(hash)),
2020-07-11 05:53:52 +00:00
{
revalidateOnMount: false,
refreshInterval: 0,
}
);
};