From d86d0fedb4a4df3f14fc4e98583164ecf4408c1a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Wed, 9 Sep 2020 21:32:43 -0700 Subject: [PATCH] Don't re-render entire file list when opening modals --- .../scripts/components/server/files/FileManagerContainer.tsx | 5 +++++ resources/scripts/plugins/useFileManagerSwr.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/scripts/components/server/files/FileManagerContainer.tsx b/resources/scripts/components/server/files/FileManagerContainer.tsx index aae93a89a..444dc2fac 100644 --- a/resources/scripts/components/server/files/FileManagerContainer.tsx +++ b/resources/scripts/components/server/files/FileManagerContainer.tsx @@ -27,6 +27,7 @@ export default () => { const id = ServerContext.useStoreState(state => state.server.data!.id); const { hash } = useLocation(); const { data: files, error, mutate } = useFileManagerSwr(); + const directory = ServerContext.useStoreState(state => state.files.directory); const clearFlashes = useStoreActions(actions => actions.flashes.clearFlashes); const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory); const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles); @@ -37,6 +38,10 @@ export default () => { setDirectory(hash.length > 0 ? hash : '/'); }, [ hash ]); + useEffect(() => { + mutate(); + }, [ directory ]); + if (error) { return ( mutate()}/> diff --git a/resources/scripts/plugins/useFileManagerSwr.ts b/resources/scripts/plugins/useFileManagerSwr.ts index eb36848bf..052393774 100644 --- a/resources/scripts/plugins/useFileManagerSwr.ts +++ b/resources/scripts/plugins/useFileManagerSwr.ts @@ -11,7 +11,8 @@ export default () => { `${uuid}:files:${directory}`, () => loadDirectory(uuid, cleanDirectoryPath(directory)), { - revalidateOnMount: true, + focusThrottleInterval: 30000, + revalidateOnMount: false, refreshInterval: 0, }, );