Fix all screens on the panel unintentionally loading the root directory for a server
This commit is contained in:
parent
52588beeb0
commit
8f0eda21c5
|
@ -1,16 +1,16 @@
|
||||||
import useWebsocketEvent from '@/plugins/useWebsocketEvent';
|
import useWebsocketEvent from '@/plugins/useWebsocketEvent';
|
||||||
import { ServerContext } from '@/state/server';
|
import { ServerContext } from '@/state/server';
|
||||||
import { SocketEvent } from '@/components/server/events';
|
import { SocketEvent } from '@/components/server/events';
|
||||||
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
|
import { mutate } from 'swr';
|
||||||
|
import { getDirectorySwrKey } from '@/plugins/useFileManagerSwr';
|
||||||
|
|
||||||
const InstallListener = () => {
|
const InstallListener = () => {
|
||||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||||
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
|
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
|
||||||
const { mutate } = useFileManagerSwr();
|
|
||||||
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
||||||
|
|
||||||
useWebsocketEvent(SocketEvent.BACKUP_RESTORE_COMPLETED, () => {
|
useWebsocketEvent(SocketEvent.BACKUP_RESTORE_COMPLETED, () => {
|
||||||
mutate(undefined);
|
mutate(getDirectorySwrKey(uuid, '/'), undefined);
|
||||||
setServerFromState(s => ({ ...s, status: null }));
|
setServerFromState(s => ({ ...s, status: null }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,14 @@ import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
|
||||||
import { cleanDirectoryPath } from '@/helpers';
|
import { cleanDirectoryPath } from '@/helpers';
|
||||||
import { ServerContext } from '@/state/server';
|
import { ServerContext } from '@/state/server';
|
||||||
|
|
||||||
|
export const getDirectorySwrKey = (uuid: string, directory: string): string => `${uuid}:files:${directory}`;
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||||
const directory = ServerContext.useStoreState(state => state.files.directory);
|
const directory = ServerContext.useStoreState(state => state.files.directory);
|
||||||
|
|
||||||
return useSWR<FileObject[]>(
|
return useSWR<FileObject[]>(
|
||||||
`${uuid}:files:${directory}`,
|
getDirectorySwrKey(uuid, directory),
|
||||||
() => loadDirectory(uuid, cleanDirectoryPath(directory)),
|
() => loadDirectory(uuid, cleanDirectoryPath(directory)),
|
||||||
{
|
{
|
||||||
focusThrottleInterval: 30000,
|
focusThrottleInterval: 30000,
|
||||||
|
|
Loading…
Reference in New Issue