Skip to content

Commit ff9f893

Browse files
committed
Code cleanup for file manager
1 parent d644758 commit ff9f893

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

resources/scripts/components/server/files/FileManagerContainer.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ export default () => {
3030
const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles);
3131

3232
useEffect(() => {
33-
// We won't automatically mutate the store when the component re-mounts, otherwise because of
34-
// my (horrible) programming this fires off way more than we intend it to.
35-
mutate();
36-
3733
setSelectedFiles([]);
3834
setDirectory(hash.length > 0 ? hash : '/');
3935
}, [ hash ]);

resources/scripts/components/server/files/FileObjectRow.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const Row = styled.div`
1818

1919
const FileObjectRow = ({ file }: { file: FileObject }) => {
2020
const directory = ServerContext.useStoreState(state => state.files.directory);
21-
const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory);
2221

2322
const history = useHistory();
2423
const match = useRouteMatch();
@@ -31,9 +30,7 @@ const FileObjectRow = ({ file }: { file: FileObject }) => {
3130
// Just trust me future me, leave this be.
3231
if (!file.isFile) {
3332
e.preventDefault();
34-
3533
history.push(`#${cleanDirectoryPath(`${directory}/${file.name}`)}`);
36-
setDirectory(`${directory}/${file.name}`);
3734
}
3835
};
3936

resources/scripts/plugins/useFileManagerSwr.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import useSWR from 'swr';
22
import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
33
import { cleanDirectoryPath } from '@/helpers';
44
import useServer from '@/plugins/useServer';
5-
import { useLocation } from 'react-router';
5+
import { ServerContext } from '@/state/server';
66

77
export default () => {
88
const { uuid } = useServer();
9-
const { hash } = useLocation();
9+
const directory = ServerContext.useStoreState(state => state.files.directory);
1010

1111
return useSWR<FileObject[]>(
12-
`${uuid}:files:${hash}`,
13-
() => loadDirectory(uuid, cleanDirectoryPath(hash)),
12+
`${uuid}:files:${directory}`,
13+
() => loadDirectory(uuid, cleanDirectoryPath(directory)),
1414
{
15-
revalidateOnMount: false,
15+
revalidateOnMount: true,
1616
refreshInterval: 0,
17-
}
17+
},
1818
);
1919
};

0 commit comments

Comments
 (0)