2020-07-11 05:38:07 +00:00
|
|
|
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,
|
|
|
|
}
|
2020-07-11 05:38:07 +00:00
|
|
|
);
|
|
|
|
};
|