Don't execute unnecessary HTTP requests when browing a file directory

This commit is contained in:
Dane Everitt 2020-04-10 13:57:24 -07:00
parent 76300209f1
commit b72a770ec9
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 17 additions and 19 deletions

View file

@ -22,20 +22,20 @@ export default () => {
const [ loading, setLoading ] = useState(true);
const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
const { id } = ServerContext.useStoreState(state => state.server.data!);
const { contents: files, directory } = ServerContext.useStoreState(state => state.files);
const { contents: files } = ServerContext.useStoreState(state => state.files);
const { getDirectoryContents } = ServerContext.useStoreActions(actions => actions.files);
useEffect(() => {
setLoading(true);
clearFlashes();
getDirectoryContents(window.location.hash.replace(/^#(\/)*/, '/'))
getDirectoryContents(window.location.hash)
.then(() => setLoading(false))
.catch(error => {
console.error(error.message, { error });
addError({ message: httpErrorToHuman(error), key: 'files' });
});
}, [ directory ]);
}, []);
return (
<div className={'my-10 mb-6'}>