diff --git a/resources/scripts/components/server/files/FileManagerContainer.tsx b/resources/scripts/components/server/files/FileManagerContainer.tsx index 520365104..def0944c2 100644 --- a/resources/scripts/components/server/files/FileManagerContainer.tsx +++ b/resources/scripts/components/server/files/FileManagerContainer.tsx @@ -30,10 +30,6 @@ export default () => { const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles); useEffect(() => { - // We won't automatically mutate the store when the component re-mounts, otherwise because of - // my (horrible) programming this fires off way more than we intend it to. - mutate(); - setSelectedFiles([]); setDirectory(hash.length > 0 ? hash : '/'); }, [ hash ]); diff --git a/resources/scripts/components/server/files/FileObjectRow.tsx b/resources/scripts/components/server/files/FileObjectRow.tsx index 9baf5b536..a78a83cc1 100644 --- a/resources/scripts/components/server/files/FileObjectRow.tsx +++ b/resources/scripts/components/server/files/FileObjectRow.tsx @@ -18,7 +18,6 @@ const Row = styled.div` const FileObjectRow = ({ file }: { file: FileObject }) => { const directory = ServerContext.useStoreState(state => state.files.directory); - const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory); const history = useHistory(); const match = useRouteMatch(); @@ -31,9 +30,7 @@ const FileObjectRow = ({ file }: { file: FileObject }) => { // Just trust me future me, leave this be. if (!file.isFile) { e.preventDefault(); - history.push(`#${cleanDirectoryPath(`${directory}/${file.name}`)}`); - setDirectory(`${directory}/${file.name}`); } }; diff --git a/resources/scripts/plugins/useFileManagerSwr.ts b/resources/scripts/plugins/useFileManagerSwr.ts index 50b69478a..16721e72c 100644 --- a/resources/scripts/plugins/useFileManagerSwr.ts +++ b/resources/scripts/plugins/useFileManagerSwr.ts @@ -2,18 +2,18 @@ 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'; +import { ServerContext } from '@/state/server'; export default () => { const { uuid } = useServer(); - const { hash } = useLocation(); + const directory = ServerContext.useStoreState(state => state.files.directory); return useSWR( - `${uuid}:files:${hash}`, - () => loadDirectory(uuid, cleanDirectoryPath(hash)), + `${uuid}:files:${directory}`, + () => loadDirectory(uuid, cleanDirectoryPath(directory)), { - revalidateOnMount: false, + revalidateOnMount: true, refreshInterval: 0, - } + }, ); };