mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 06:43:45 +02:00
Continue with file manager code cleanup
This commit is contained in:
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)),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user