Don't execute unnecessary HTTP requests when browing a file directory
This commit is contained in:
parent
76300209f1
commit
b72a770ec9
6 changed files with 17 additions and 19 deletions
|
@ -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'}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue