1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-23 01:22:30 +01:00

Don't re-render entire file list when opening modals

This commit is contained in:
Dane Everitt 2020-09-09 21:32:43 -07:00
parent deb61623b2
commit d86d0fedb4
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 7 additions and 1 deletions

View File

@ -27,6 +27,7 @@ export default () => {
const id = ServerContext.useStoreState(state => state.server.data!.id); const id = ServerContext.useStoreState(state => state.server.data!.id);
const { hash } = useLocation(); const { hash } = useLocation();
const { data: files, error, mutate } = useFileManagerSwr(); const { data: files, error, mutate } = useFileManagerSwr();
const directory = ServerContext.useStoreState(state => state.files.directory);
const clearFlashes = useStoreActions(actions => actions.flashes.clearFlashes); const clearFlashes = useStoreActions(actions => actions.flashes.clearFlashes);
const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory); const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory);
const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles); const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles);
@ -37,6 +38,10 @@ export default () => {
setDirectory(hash.length > 0 ? hash : '/'); setDirectory(hash.length > 0 ? hash : '/');
}, [ hash ]); }, [ hash ]);
useEffect(() => {
mutate();
}, [ directory ]);
if (error) { if (error) {
return ( return (
<ServerError message={httpErrorToHuman(error)} onRetry={() => mutate()}/> <ServerError message={httpErrorToHuman(error)} onRetry={() => mutate()}/>

View File

@ -11,7 +11,8 @@ export default () => {
`${uuid}:files:${directory}`, `${uuid}:files:${directory}`,
() => loadDirectory(uuid, cleanDirectoryPath(directory)), () => loadDirectory(uuid, cleanDirectoryPath(directory)),
{ {
revalidateOnMount: true, focusThrottleInterval: 30000,
revalidateOnMount: false,
refreshInterval: 0, refreshInterval: 0,
}, },
); );