Continue with file manager code cleanup
This commit is contained in:
parent
2692e98cd8
commit
5da9824fb7
4 changed files with 89 additions and 150 deletions
15
resources/scripts/plugins/useFileManagerSwr.ts
Normal file
15
resources/scripts/plugins/useFileManagerSwr.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
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)),
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue