diff --git a/resources/scripts/components/server/InstallListener.tsx b/resources/scripts/components/server/InstallListener.tsx index c0a7f6ac..fbf377a2 100644 --- a/resources/scripts/components/server/InstallListener.tsx +++ b/resources/scripts/components/server/InstallListener.tsx @@ -1,16 +1,16 @@ import useWebsocketEvent from '@/plugins/useWebsocketEvent'; import { ServerContext } from '@/state/server'; import { SocketEvent } from '@/components/server/events'; -import useFileManagerSwr from '@/plugins/useFileManagerSwr'; +import { mutate } from 'swr'; +import { getDirectorySwrKey } from '@/plugins/useFileManagerSwr'; const InstallListener = () => { const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const getServer = ServerContext.useStoreActions(actions => actions.server.getServer); - const { mutate } = useFileManagerSwr(); const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState); useWebsocketEvent(SocketEvent.BACKUP_RESTORE_COMPLETED, () => { - mutate(undefined); + mutate(getDirectorySwrKey(uuid, '/'), undefined); setServerFromState(s => ({ ...s, status: null })); }); diff --git a/resources/scripts/plugins/useFileManagerSwr.ts b/resources/scripts/plugins/useFileManagerSwr.ts index 390ce839..e134cb40 100644 --- a/resources/scripts/plugins/useFileManagerSwr.ts +++ b/resources/scripts/plugins/useFileManagerSwr.ts @@ -3,12 +3,14 @@ import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory'; import { cleanDirectoryPath } from '@/helpers'; import { ServerContext } from '@/state/server'; +export const getDirectorySwrKey = (uuid: string, directory: string): string => `${uuid}:files:${directory}`; + export default () => { const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const directory = ServerContext.useStoreState(state => state.files.directory); return useSWR( - `${uuid}:files:${directory}`, + getDirectorySwrKey(uuid, directory), () => loadDirectory(uuid, cleanDirectoryPath(directory)), { focusThrottleInterval: 30000,